OTest2
A C++ testing framework
casegenerated.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Ondrej Starek
3  *
4  * This file is part of OTest2.
5  *
6  * OTest2 is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License,
9  * or (at your option) any later version.
10  *
11  * OTest2 is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with OTest2. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OTest2INCLUDE_CASEGENERATED_H_
21 #define OTest2INCLUDE_CASEGENERATED_H_
22 
23 #include <string>
24 
25 #include <otest2/caseordinary.h>
26 #include <otest2/contextobject.h>
27 #include <otest2/fcemarshalerptr.h>
28 #include <otest2/stateptr.h>
29 
30 namespace OTest2 {
31 
32 class Context;
33 
37 class CaseGenerated : public CaseOrdinary, public ContextObject {
38  private:
39  struct Impl;
40  Impl* pimpl;
41 
42  public:
43  /* -- avoid copying */
45  const CaseGenerated&) = delete;
47  const CaseGenerated&) = delete;
48 
55  explicit CaseGenerated(
56  const Context& context_,
57  const std::string& name_);
58 
62  virtual ~CaseGenerated();
63 
64  /* -- object interface */
65  virtual std::string getName() const;
66 
67  /* -- scenario object */
68  virtual bool startUpObject(
69  const Context& context_,
70  int index_) override;
71  virtual void scheduleBody(
72  const Context& context_,
73  ScenarioPtr scenario_,
74  ObjectPtr me_) override;
75  virtual void tearDownObject(
76  const Context& context_,
77  int index_) override;
78 
79  /* -- ordinary case */
80  virtual StatePtr getFirstState() const override;
81  virtual StatePtr getState(
82  const std::string& name_) const override;
83 
84  /* -- context object */
85  virtual const Context& otest2Context() const;
86 
87  protected:
94  void registerState(
95  const std::string& name_,
96  StatePtr state_);
97 
103  void setEnteringState(
104  const std::string& name_);
105 
109  void registerFixture(
110  FceMarshalerPtr start_up_,
111  FceMarshalerPtr tear_down_);
112 };
113 
114 } /* -- namespace OTest2 */
115 
116 #endif /* -- OTest2INCLUDE_CASEGENERATED_H_ */
OTest2::CaseGenerated::getName
virtual std::string getName() const
Get object's name.
Definition: casegenerated.cpp:92
OTest2::CaseGenerated::operator=
CaseGenerated & operator=(const CaseGenerated &)=delete
OTest2::CaseGenerated::tearDownObject
virtual void tearDownObject(const Context &context_, int index_) override
Execute tear-down function at specified index.
Definition: casegenerated.cpp:120
OTest2::CaseGenerated::otest2Context
virtual const Context & otest2Context() const
Get the OTest2 context.
Definition: casegenerated.cpp:139
OTest2::CaseGenerated::setEnteringState
void setEnteringState(const std::string &name_)
Set name of the entering (first) state.
Definition: casegenerated.cpp:149
OTest2::CaseGenerated::~CaseGenerated
virtual ~CaseGenerated()
Dtor.
Definition: casegenerated.cpp:88
caseordinary.h
fcemarshalerptr.h
OTest2::CaseGenerated
Common implementation of a generated test case.
Definition: casegenerated.h:37
OTest2::FceMarshalerPtr
std::shared_ptr< FceMarshaler > FceMarshalerPtr
Definition: fcemarshalerptr.h:27
OTest2::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Shared pointer to a testing object.
Definition: objectptr.h:27
OTest2::CaseGenerated::getState
virtual StatePtr getState(const std::string &name_) const override
Get state with specified name_.
Definition: casegenerated.cpp:134
OTest2
Definition: assertbean.h:25
OTest2::CaseGenerated::startUpObject
virtual bool startUpObject(const Context &context_, int index_) override
Execute start-up function at specified index.
Definition: casegenerated.cpp:96
OTest2::ContextObject
A generic interface of objects which offers OTest2 context.
Definition: contextobject.h:33
OTest2::ScenarioPtr
std::shared_ptr< Scenario > ScenarioPtr
Shared pointer of the scenario object.
Definition: scenarioptr.h:27
OTest2::CaseGenerated::registerFixture
void registerFixture(FceMarshalerPtr start_up_, FceMarshalerPtr tear_down_)
Register a pair of start-up and tear-down functions.
Definition: casegenerated.cpp:154
OTest2::StatePtr
std::shared_ptr< State > StatePtr
Pointer to test state objects.
Definition: stateptr.h:27
OTest2::CaseOrdinary
An ordinary case object scheduled by the CmdFirstState, CmdRunState and CmdState commands.
Definition: caseordinary.h:37
OTest2::CaseGenerated::getFirstState
virtual StatePtr getFirstState() const override
Get the initial state.
Definition: casegenerated.cpp:130
OTest2::CaseGenerated::CaseGenerated
CaseGenerated(const CaseGenerated &)=delete
OTest2::CaseGenerated::registerState
void registerState(const std::string &name_, StatePtr state_)
Register new test state.
Definition: casegenerated.cpp:143
stateptr.h
OTest2::Context
OTest2 runtime context.
Definition: context.h:38
contextobject.h
OTest2::CaseGenerated::scheduleBody
virtual void scheduleBody(const Context &context_, ScenarioPtr scenario_, ObjectPtr me_) override
Schedule body of the testing object.
Definition: casegenerated.cpp:109