00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #define MOCKPP_NEED_EXPORTS
00032 #include <mockpp/mockpp.h>
00033
00034 #include <mockpp/visiting/VisitableMockObject.h>
00035
00036
00037 MOCKPP_NS_START
00038
00039
00040 MOCKPP_API_IMPL0 VisitableMockObjectBase::VisitableMockObjectBase(const String &name, VerifiableList *parent)
00041 :methodList(name+MOCKPP_PCSTRING("/methodList"), parent)
00042 {
00043 activated = false;
00044 }
00045
00046
00047 MOCKPP_API_IMPL0 VisitableMockObjectBase::~VisitableMockObjectBase()
00048 {
00049 }
00050
00051
00052 MOCKPP_API_IMPL(void) VisitableMockObjectBase::addExpectedMethod(const MOCKPP_STL::string &name) const
00053 {
00054 MOCKPP_ASSERT_EQUALS(isActivated(), false);
00055 methodList.addExpected(name);
00056 }
00057
00058
00059 MOCKPP_API_IMPL(void) VisitableMockObjectBase::addActualMethod(const MOCKPP_STL::string &name) const
00060 {
00061 MOCKPP_ASSERT_EQUALS(isActivated(), true);
00062 methodList.addActual(name);
00063 }
00064
00065
00066 MOCKPP_API_IMPL(void) VisitableMockObjectBase::activate()
00067 {
00068 activated = true;
00069 }
00070
00071
00072 MOCKPP_API_IMPL(bool) VisitableMockObjectBase::isActivated() const
00073 {
00074 return activated;
00075 }
00076
00077
00078 MOCKPP_API_IMPL(void) VisitableMockObjectBase::visitableVerify()
00079 {
00080 methodList.verify();
00081 for (unsigned i = 0; i < controllers.size(); ++i)
00082 controllers[i]->verify();
00083 }
00084
00085
00086 MOCKPP_API_IMPL(void) VisitableMockObjectBase::visitableReset()
00087 {
00088 activated = false;
00089 for (unsigned i = 0; i < controllers.size(); ++i)
00090 controllers[i]->reset();
00091 }
00092
00093
00094 MOCKPP_API_IMPL(void) VisitableMockObjectBase::unsetThrowablesInline()
00095 {
00096 for (unsigned i = 0; i < controllers.size(); ++i)
00097 controllers[i]->unsetThrowablesInline();
00098 }
00099
00100
00101 MOCKPP_API_IMPL(void) VisitableMockObjectBase::addController (Controller *ctr)
00102 {
00103 controllers.push_back(ctr);
00104 }
00105
00106
00107 MOCKPP_API_IMPL(void) VisitableMockObjectBase::removeController (Controller *ctr)
00108 {
00109 MOCKPP_STL::vector<Controller*>::iterator it =
00110 MOCKPP_STL::find (controllers.begin(), controllers.end(), ctr);
00111 if (it != controllers.end())
00112 controllers.erase(it);
00113 }
00114
00115
00116 MOCKPP_API_IMPL(unsigned) VisitableMockObjectBase::numController() const
00117 {
00118 return controllers.size();
00119 }
00120
00121
00123
00124
00125 MOCKPP_API_IMPL0 VisitableMockObject::VisitableMockObject(const String &name, VerifiableList *parent)
00126 : MockObject(name, parent)
00127 , VisitableMockObjectBase(name, this)
00128 {
00129 }
00130
00131
00132 MOCKPP_API_IMPL0 VisitableMockObject::~VisitableMockObject()
00133 {
00134 }
00135
00136
00137 MOCKPP_API_IMPL(void) VisitableMockObject::verify()
00138 {
00139 MockObject::verify();
00140 visitableVerify();
00141 }
00142
00143
00144 MOCKPP_API_IMPL(void) VisitableMockObject::reset()
00145 {
00146 MockObject::reset();
00147 visitableReset();
00148 }
00149
00150
00152
00153
00154 MOCKPP_API_IMPL0 VisitableMockObjectBase::Controller::~Controller()
00155 {
00156 }
00157
00158
00159 MOCKPP_NS_END