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_VisitableMockMethod6_H
00032 #define MOCKPP_VisitableMockMethod6_H
00033
00034 #include <mockpp/mockpp.h>
00035
00036 #include <mockpp/visiting/VisitableMockObject.h>
00037 #include <mockpp/visiting/VisitableMockMethod.h>
00038 #include <mockpp/visiting/ResponseVector6.h>
00039
00040
00041 MOCKPP_NS_START
00042
00043
00047 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00048 class VisitableMockMethod6Common : public VisitableMockReturningMethodBase<R>
00049 {
00050 public:
00051
00056 VisitableMockMethod6Common(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 , parameter6(this->getMethodName() + MOCKPP_PCHAR("/parameter6"), this)
00065 {
00066 }
00067
00068
00077 void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, const ConstraintHolder<P6> &p6) const
00078 {
00079 MOCKPP_ASSERT_FALSE_MESSAGE(this->getVisitableMockObject()->getVerifiableName() + MOCKPP_PCHAR(".isActivated() != true"),
00080 this->getVisitableMockObject()->isActivated());
00081 this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());
00082 parameter1.addExpected(p1);
00083 parameter2.addExpected(p2);
00084 parameter3.addExpected(p3);
00085 parameter4.addExpected(p4);
00086 parameter5.addExpected(p5);
00087 parameter6.addExpected(p6);
00088 }
00089
00090 protected:
00091
00100 void forward_param(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) const
00101 {
00102 if (!this->getVisitableMockObject()->isActivated() )
00103 {
00104 this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());
00105 parameter1.addExpected(p1);
00106 parameter2.addExpected(p2);
00107 parameter3.addExpected(p3);
00108 parameter4.addExpected(p4);
00109 parameter5.addExpected(p5);
00110 parameter6.addExpected(p6);
00111 }
00112
00113 else
00114 {
00115 MOCKPP_TRY
00116 {
00117 this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier());
00118
00119 Throwable *t;
00120 if (this->responseThrowables.find(t, p1, p2, p3, p4, p5, p6))
00121 t->throw_me();
00122
00123 this->throwAvailableException();
00124 }
00125
00126 MOCKPP_CATCH_ALL
00127 {
00128 parameter1.balanceActual();
00129 parameter2.balanceActual();
00130 parameter3.balanceActual();
00131 parameter4.balanceActual();
00132 parameter5.balanceActual();
00133 parameter6.balanceActual();
00134 MOCKPP_RETHROW;
00135 }
00136
00137 parameter1.addActual(p1);
00138 parameter2.addActual(p2);
00139 parameter3.addActual(p3);
00140 parameter4.addActual(p4);
00141 parameter5.addActual(p5);
00142 parameter6.addActual(p6);
00143 }
00144 }
00145
00146 public:
00147
00160 void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6, unsigned count = MOCKPP_UNLIMITED)
00161 {
00162 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00163 this->responseThrowables.add(t, p1, p2, p3, p4, p5, p6, count);
00164 }
00165
00178 void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, const ConstraintHolder<P6> &p6, unsigned count = MOCKPP_UNLIMITED)
00179 {
00180 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00181 this->responseThrowables.add(t, p1, p2, p3, p4, p5, p6, count);
00182 }
00183
00184 private:
00185
00186 mutable ResponseThrowableVector6<P1, P2, P3, P4, P5, P6> responseThrowables;
00187
00188 mutable ConstraintList<P1> parameter1;
00189 mutable ConstraintList<P2> parameter2;
00190 mutable ConstraintList<P3> parameter3;
00191 mutable ConstraintList<P4> parameter4;
00192 mutable ConstraintList<P5> parameter5;
00193 mutable ConstraintList<P6> parameter6;
00194 };
00195
00196
00200 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00201 class VisitableMockMethod6
00202 : public VisitableMockMethod6Common<R, P1, P2, P3, P4, P5, P6>
00203 {
00204 public:
00205
00210 VisitableMockMethod6(const String &name, VisitableMockObject *parent)
00211 : VisitableMockMethod6Common<R, P1, P2, P3, P4, P5, P6>(name, parent)
00212 , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this)
00213 {
00214 }
00215
00225 R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) const
00226 {
00227 this->forward_param(p1, p2, p3, p4, p5, p6);
00228
00229 if (this->getVisitableMockObject()->isActivated() )
00230 {
00231 R ret_val;
00232 if (this->responseValues.find(ret_val, p1, p2, p3, p4, p5, p6))
00233 return ret_val;
00234
00235 return this->determineReturnValue();
00236 }
00237 else
00238 return R();
00239 }
00240
00241 #if defined(__BORLANDC__) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000
00242
00250 void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, const ConstraintHolder<P6> &p6) const
00251 {
00252 VisitableMockMethod6Common<R, P1, P2, P3, P4, P5, P6>::forward(p1, p2, p3, p4, p5, p6);
00253 }
00254 #else
00255 using VisitableMockMethod6Common<R, P1, P2, P3, P4, P5, P6>::forward;
00256 #endif
00257
00270 void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6, unsigned count = MOCKPP_UNLIMITED)
00271 {
00272 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00273 this->responseValues.add(rv, p1, p2, p3, p4, p5, p6, count);
00274 }
00275
00288 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, const ConstraintHolder<P6> &p6, unsigned count = MOCKPP_UNLIMITED)
00289 {
00290 MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated());
00291 this->responseValues.add(rv, p1, p2, p3, p4, p5, p6, count);
00292 }
00293
00294 private:
00295
00296 mutable ResponseVector6<R, P1, P2, P3, P4, P5, P6> responseValues;
00297 };
00298
00299
00304 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00305 class VisitableMockMethod6<void, P1, P2, P3, P4, P5, P6>
00306 : public VisitableMockMethod6Common<void, P1, P2, P3, P4, P5, P6>
00307 {
00308 public:
00309
00314 VisitableMockMethod6(const String &name, VisitableMockObject *parent)
00315 : VisitableMockMethod6Common<void, P1, P2, P3, P4, P5, P6>(name, parent)
00316 {
00317 }
00318
00328 void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) const
00329 {
00330 this->forward_param(p1, p2, p3, p4, p5, p6);
00331 }
00332
00333 #if defined(__BORLANDC__) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000
00334
00342 void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, const ConstraintHolder<P6> &p6) const
00343 {
00344 VisitableMockMethod6Common<void, P1, P2, P3, P4, P5, P6>::forward(p1, p2, p3, p4, p5, p6);
00345 }
00346 #else
00347 using VisitableMockMethod6Common<void, P1, P2, P3, P4, P5, P6>::forward;
00348 #endif
00349 };
00350
00351
00352 MOCKPP_NS_END
00353
00354
00355 #endif // MOCKPP_VisitableMockMethod6_H
00356