00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef MOCKPP_VisitableMockMethod5_H
00032 #define MOCKPP_VisitableMockMethod5_H
00033
00034 #include <mockpp/mockpp.h>
00035
00036 #include <mockpp/visiting/VisitableMockObject.h>
00037 #include <mockpp/visiting/VisitableMockMethod.h>
00038 #include <mockpp/visiting/ResponseVector5.h>
00039
00040
00041 MOCKPP_NS_START
00042
00043
00047 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
00048 class VisitableMockMethod5Common : public VisitableMockReturningMethodBase<R>
00049 {
00050 public:
00051
00056 VisitableMockMethod5Common(const String &name, VisitableMockObject *parent)
00057 : VisitableMockReturningMethodBase<R>(name, parent)
00058 , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this)
00059 , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this)
00060 , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this)
00061 , parameter3(this->getMethodName() + MOCKPP_PCHAR("/parameter3"), this)
00062 , parameter4(this->getMethodName() + MOCKPP_PCHAR("/parameter4"), this)
00063 , parameter5(this->getMethodName() + MOCKPP_PCHAR("/parameter5"), this)
00064 {
00065 }
00066
00067
00075 void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5) const
00076 {
00077 MOCKPP_ASSERT_FALSE_MESSAGE(this->getVisitableMockObject()->getVerifiableName() + MOCKPP_PCHAR(".isActivated() != true"),
00078 this->getVisitableMockObject()->isActivated());
00079 this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());
00080 parameter1.addExpected(p1);
00081 parameter2.addExpected(p2);
00082 parameter3.addExpected(p3);
00083 parameter4.addExpected(p4);
00084 parameter5.addExpected(p5);
00085 }
00086
00087 protected:
00088
00096 void forward_param(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const
00097 {
00098 if (!this->getVisitableMockObject()->isActivated() )
00099 {
00100 this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());
00101 parameter1.addExpected(p1);
00102 parameter2.addExpected(p2);
00103 parameter3.addExpected(p3);
00104 parameter4.addExpected(p4);
00105 parameter5.addExpected(p5);
00106 }
00107
00108 else
00109 {
00110 MOCKPP_TRY
00111 {
00112 this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier());
00113
00114 Throwable *t;
00115 if (this->responseThrowables.find(t, p1, p2, p3, p4, p5))
00116 t->throw_me();
00117
00118 this->throwAvailableException();
00119 }
00120
00121 MOCKPP_CATCH_ALL
00122 {
00123 parameter1.balanceActual();
00124 parameter2.balanceActual();
00125 parameter3.balanceActual();
00126 parameter4.balanceActual();
00127 parameter5.balanceActual();
00128 MOCKPP_RETHROW;
00129 }
00130
00131 parameter1.addActual(p1);
00132 parameter2.addActual(p2);
00133 parameter3.addActual(p3);
00134 parameter4.addActual(p4);
00135 parameter5.addActual(p5);
00136 }
00137 }
00138
00139 public:
00140
00152 void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count = MOCKPP_UNLIMITED)
00153 {
00154 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00155 this->responseThrowables.add(t, p1, p2, p3, p4, p5, count);
00156 }
00157
00169 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)
00170 {
00171 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00172 this->responseThrowables.add(t, p1, p2, p3, p4, p5, count);
00173 }
00174
00175 private:
00176
00177 mutable ResponseThrowableVector5<P1, P2, P3, P4, P5> responseThrowables;
00178
00179 mutable ConstraintList<P1> parameter1;
00180 mutable ConstraintList<P2> parameter2;
00181 mutable ConstraintList<P3> parameter3;
00182 mutable ConstraintList<P4> parameter4;
00183 mutable ConstraintList<P5> parameter5;
00184 };
00185
00186
00190 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
00191 class VisitableMockMethod5
00192 : public VisitableMockMethod5Common<R, P1, P2, P3, P4, P5>
00193 {
00194 public:
00195
00200 VisitableMockMethod5(const String &name, VisitableMockObject *parent)
00201 : VisitableMockMethod5Common<R, P1, P2, P3, P4, P5>(name, parent)
00202 , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this)
00203 {
00204 }
00205
00214 R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const
00215 {
00216 this->forward_param(p1, p2, p3, p4, p5);
00217
00218 if (this->getVisitableMockObject()->isActivated() )
00219 {
00220 R ret_val;
00221 if (this->responseValues.find(ret_val, p1, p2, p3, p4, p5))
00222 return ret_val;
00223
00224 return this->determineReturnValue();
00225 }
00226 else
00227 return R();
00228 }
00229
00230 #if defined(__BORLANDC__) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000
00231
00238 void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5) const
00239 {
00240 VisitableMockMethod5Common<R, P1, P2, P3, P4, P5>::forward(p1, p2, p3, p4, p5);
00241 }
00242 #else
00243 using VisitableMockMethod5Common<R, P1, P2, P3, P4, P5>::forward;
00244 #endif
00245
00257 void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count = MOCKPP_UNLIMITED)
00258 {
00259 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00260 this->responseValues.add(rv, p1, p2, p3, p4, p5, count);
00261 }
00262
00274 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)
00275 {
00276 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00277 this->responseValues.add(rv, p1, p2, p3, p4, p5, count);
00278 }
00279
00280 private:
00281
00282 mutable ResponseVector5<R, P1, P2, P3, P4, P5> responseValues;
00283 };
00284
00285
00290 template <typename P1, typename P2, typename P3, typename P4, typename P5>
00291 class VisitableMockMethod5<void, P1, P2, P3, P4, P5>
00292 : public VisitableMockMethod5Common<void, P1, P2, P3, P4, P5>
00293 {
00294 public:
00295
00300 VisitableMockMethod5(const String &name, VisitableMockObject *parent)
00301 : VisitableMockMethod5Common<void, P1, P2, P3, P4, P5>(name, parent)
00302 {
00303 }
00304
00313 void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const
00314 {
00315 this->forward_param(p1, p2, p3, p4, p5);
00316 }
00317
00318 #if defined(__BORLANDC__) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000
00319
00326 void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5) const
00327 {
00328 VisitableMockMethod5Common<void, P1, P2, P3, P4, P5>::forward(p1, p2, p3, p4, p5);
00329 }
00330 #else
00331 using VisitableMockMethod5Common<void, P1, P2, P3, P4, P5>::forward;
00332 #endif
00333 };
00334
00335
00336 MOCKPP_NS_END
00337
00338
00339 #endif // MOCKPP_VisitableMockMethod5_H
00340