00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef MOCKPP_INVOKEDBEFOREMATCHER_H
00031 #define MOCKPP_INVOKEDBEFOREMATCHER_H
00032
00033 #include <mockpp/mockpp.h>
00034
00035 #include <mockpp/matcher/StatelessInvocationMatcher.h>
00036 #include <mockpp/matcher/InvokedRecorder.h>
00037
00038
00039 MOCKPP_NS_START
00040
00041
00046 template <typename I>
00047 class InvokedBeforeMatcher : public StatelessInvocationMatcher<I>
00048 {
00049 public:
00050
00055 InvokedBeforeMatcher( InvokedRecorder *in_subsequentCallRecorder,
00056 const String &in_subsequentCallDescription )
00057 : subsequentCallRecorder(in_subsequentCallRecorder)
00058 , subsequentCallDescription(in_subsequentCallDescription)
00059 {}
00060
00065 virtual bool matches( const I &invocation )
00066 {
00067 MOCKPP_UNUSED(invocation);
00068 return !subsequentCallRecorder->hasBeenInvoked();
00069 }
00070
00074 virtual void incInvoked( const I &invocation )
00075 {
00076 if (!matches(invocation))
00077 assertionFailed(__LINE__, __FILE__,
00078 MOCKPP_PCHAR("called out of order; should be called before ")
00079 + subsequentCallDescription);
00080 }
00081
00086 virtual String describeTo( String &buffer ) const
00087 {
00088 buffer += MOCKPP_PCHAR("before ") + subsequentCallDescription;
00089 if( subsequentCallRecorder->hasBeenInvoked() )
00090 buffer += MOCKPP_PCHAR(" (invoked)");
00091 else
00092 buffer += MOCKPP_PCHAR(" (not invoked)");
00093
00094 return buffer;
00095 }
00096
00097 private:
00098
00099 InvokedRecorder *subsequentCallRecorder;
00100 String subsequentCallDescription;
00101
00102 };
00103
00104
00105 MOCKPP_NS_END
00106
00107
00108 #endif // MOCKPP_INVOKEDBEFOREMATCHER_H
00109