Thread: [Mockpp-commits] mockpp/mockpp VisitableMockMethod0.h,NONE,1.1 VisitableMockMethod1.h,NONE,1.1 Visit
Brought to you by:
ewald-arnold
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30974/mockpp Added Files: VisitableMockMethod0.h VisitableMockMethod1.h VisitableMockMethod2.h VisitableMockMethod3.h VisitableMockMethod4.h VisitableMockMethod5.h Log Message: new --- NEW FILE: VisitableMockMethod2.h --- /** @file @brief Visitable Mock Method with 2 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod2.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_VisitableMockMethod2_H #define MOCKPP_VisitableMockMethod2_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector2.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 2 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2> class VisitableMockMethod2Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod2Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 */ void forward_param(const P1 &p1, const P2 &p2) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector2<P1, P2> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; }; /** Set up visitable mock method expectations with 2 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2> class VisitableMockMethod2 : public VisitableMockMethod2Common<R, P1, P2> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod2(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod2Common<R, P1, P2>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 */ R forward(const P1 &p1, const P2 &p2) const { this->forward_param(p1, p2); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, count); } }; friend class ControllerFor; private: mutable ResponseVector2<R, P1, P2> responseValues; }; /** Set up visitable mock method expectations with 2 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2> class VisitableMockMethod2<void, P1, P2> : public VisitableMockMethod2Common<void, P1, P2> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod2(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod2Common<void, P1, P2>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 */ void forward(const P1 &p1, const P2 &p2) const { this->forward_param(p1, p2); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod2_H --- NEW FILE: VisitableMockMethod3.h --- /** @file @brief Visitable Mock Method with 3 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod3.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_VisitableMockMethod3_H #define MOCKPP_VisitableMockMethod3_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector3.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 3 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3> class VisitableMockMethod3Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod3Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) , parameter3(this->getMethodName() + MOCKPP_PCHAR("/parameter3"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 */ void forward_param(const P1 &p1, const P2 &p2, const P3 &p3) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2, p3)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector3<P1, P2, P3> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; mutable ConstraintList<P3> parameter3; }; /** Set up visitable mock method expectations with 3 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3> class VisitableMockMethod3 : public VisitableMockMethod3Common<R, P1, P2, P3> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod3(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod3Common<R, P1, P2, P3>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3) const { this->forward_param(p1, p2, p3); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2, p3)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, count); } }; friend class ControllerFor; private: mutable ResponseVector3<R, P1, P2, P3> responseValues; }; /** Set up visitable mock method expectations with 3 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3> class VisitableMockMethod3<void, P1, P2, P3> : public VisitableMockMethod3Common<void, P1, P2, P3> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod3(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod3Common<void, P1, P2, P3>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3) const { this->forward_param(p1, p2, p3); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod3_H --- NEW FILE: VisitableMockMethod4.h --- /** @file @brief Visitable Mock Method with 4 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod4.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_VisitableMockMethod4_H #define MOCKPP_VisitableMockMethod4_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector4.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 4 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4> class VisitableMockMethod4Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod4Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) , parameter3(this->getMethodName() + MOCKPP_PCHAR("/parameter3"), this) , parameter4(this->getMethodName() + MOCKPP_PCHAR("/parameter4"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 */ void forward_param(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2, p3, p4)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); parameter4.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); parameter4.addActual(p4); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector4<P1, P2, P3, P4> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; mutable ConstraintList<P3> parameter3; mutable ConstraintList<P4> parameter4; }; /** Set up visitable mock method expectations with 4 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4> class VisitableMockMethod4 : public VisitableMockMethod4Common<R, P1, P2, P3, P4> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod4(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod4Common<R, P1, P2, P3, P4>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { this->forward_param(p1, p2, p3, p4); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2, p3, p4)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, count); } }; friend class ControllerFor; private: mutable ResponseVector4<R, P1, P2, P3, P4> responseValues; }; /** Set up visitable mock method expectations with 4 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3, typename P4> class VisitableMockMethod4<void, P1, P2, P3, P4> : public VisitableMockMethod4Common<void, P1, P2, P3, P4> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod4(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod4Common<void, P1, P2, P3, P4>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { this->forward_param(p1, p2, p3, p4); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod4_H --- NEW FILE: VisitableMockMethod0.h --- /** @file @brief Visitable Mock Method with 0 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod0.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_VisitableMockMethod0_H #define MOCKPP_VisitableMockMethod0_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector0.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 0 parameters. * @ingroup grp_controller */ template <typename R> class VisitableMockMethod0Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod0Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) { } /** Set up expectations with constraints. */ void forward () const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); } protected: /** Perform the internals to verify a mocked method. */ void forward_param() const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); } else { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); this->throwAvailableException(); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; /** Set up visitable mock method expectations with 0 parameters. * @ingroup grp_controller */ template <typename R> class VisitableMockMethod0 : public VisitableMockMethod0Common<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod0(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod0Common<R>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. */ R forward() const { this->forward_param(); return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; /** Set up visitable mock method expectations with 0 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <> class VisitableMockMethod0<void> : public VisitableMockMethod0Common<void> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod0(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod0Common<void>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. */ void forward() const { this->forward_param(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod0_H --- NEW FILE: VisitableMockMethod5.h --- /** @file @brief Visitable Mock Method with 5 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod5.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_VisitableMockMethod5_H #define MOCKPP_VisitableMockMethod5_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector5.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 5 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class VisitableMockMethod5Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod5Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) , parameter3(this->getMethodName() + MOCKPP_PCHAR("/parameter3"), this) , parameter4(this->getMethodName() + MOCKPP_PCHAR("/parameter4"), this) , parameter5(this->getMethodName() + MOCKPP_PCHAR("/parameter5"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); parameter5.addExpected(p5); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 */ void forward_param(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); parameter5.addExpected(p5); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2, p3, p4, p5)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); parameter4.balanceActual(); parameter5.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); parameter4.addActual(p4); parameter5.addActual(p5); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, p5, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, p5, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector5<P1, P2, P3, P4, P5> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; mutable ConstraintList<P3> parameter3; mutable ConstraintList<P4> parameter4; mutable ConstraintList<P5> parameter5; }; /** Set up visitable mock method expectations with 5 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class VisitableMockMethod5 : public VisitableMockMethod5Common<R, P1, P2, P3, P4, P5> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod5(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod5Common<R, P1, P2, P3, P4, P5>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { this->forward_param(p1, p2, p3, p4, p5); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2, p3, p4, p5)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, p5, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, p5, count); } }; friend class ControllerFor; private: mutable ResponseVector5<R, P1, P2, P3, P4, P5> responseValues; }; /** Set up visitable mock method expectations with 5 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3, typename P4, typename P5> class VisitableMockMethod5<void, P1, P2, P3, P4, P5> : public VisitableMockMethod5Common<void, P1, P2, P3, P4, P5> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod5(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod5Common<void, P1, P2, P3, P4, P5>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { this->forward_param(p1, p2, p3, p4, p5); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod5_H --- NEW FILE: VisitableMockMethod1.h --- /** @file @brief Visitable Mock Method with 1 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod1.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_VisitableMockMethod1_H #define MOCKPP_VisitableMockMethod1_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector1.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 1 parameters. * @ingroup grp_controller */ template <typename R, typename P1> class VisitableMockMethod1Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod1Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 */ void forward (const ConstraintHolder<P1> &p1) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 */ void forward_param(const P1 &p1) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); throw; } parameter1.addActual(p1); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector1<P1> responseThrowables; mutable ConstraintList<P1> parameter1; }; /** Set up visitable mock method expectations with 1 parameters. * @ingroup grp_controller */ template <typename R, typename P1> class VisitableMockMethod1 : public VisitableMockMethod1Common<R, P1> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod1(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod1Common<R, P1>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 */ R forward(const P1 &p1) const { this->forward_param(p1); R ret_val; if (this->method->responseValues.find(ret_val, p1)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, unsigned count = MOCKPP_UNLIMITED) ... [truncated message content] |