00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef MOCKPP_DYNAMICCHAININGMOCKERROR_H
00036 #define MOCKPP_DYNAMICCHAININGMOCKERROR_H
00037
00038
00039 #include <mockpp/mockpp.h>
00040
00041 #include <mockpp/chaining/DynamicChainingMock.h>
00042 #include <mockpp/chaining/InvocationDispatcher.h>
00043 #include <mockpp/chaining/Invocation.h>
00044
00045 #include <mockpp/compat/AssertionFailedError.h>
00046
00047
00048 MOCKPP_NS_START
00049
00050
00054 template <typename R,
00055 typename I>
00056 class DynamicChainingMockError : public AssertionFailedError
00057 {
00058 public:
00059
00066 DynamicChainingMockError( DynamicChainingMock<R, I> *in_dynamicMock,
00067 const I &in_invocation,
00068 InvocationDispatcher<R, I> *in_dispatcher,
00069 const String &in_message )
00070 : AssertionFailedError( __LINE__, __FILE__, in_message )
00071 , dynamicMock( in_dynamicMock )
00072 , invocation( in_invocation )
00073 , dispatcher( in_dispatcher )
00074
00075 {}
00076
00077
00080 virtual ~DynamicChainingMockError() throw()
00081 {}
00082
00083
00088 String writeTo( String &buffer ) const
00089 {
00090 buffer += dynamicMock->toString();
00091 buffer += MOCKPP_PCHAR( ": " );
00092 buffer += AssertionFailedError::getMessage();
00093 buffer += MOCKPP_PCHAR( "\n" );
00094 buffer += MOCKPP_PCHAR( "Invoked: " );
00095 buffer = invocation.describeTo( buffer );
00096 buffer += MOCKPP_PCHAR( "\n" );
00097 buffer += MOCKPP_PCHAR( "Allowed: " );
00098 buffer = dispatcher->describeTo( buffer );
00099 return buffer;
00100 }
00101
00102
00106 virtual String getMessage() const
00107 {
00108 String s;
00109 return writeTo(s);
00110 }
00111
00112 private:
00113
00114 DynamicChainingMock<R, I>* dynamicMock;
00115 I invocation;
00116 InvocationDispatcher<R, I>* dispatcher;
00117 };
00118
00119
00120 MOCKPP_NS_END
00121
00122
00123 #endif // MOCKPP_DYNAMICCHAININGMOCKERROR_H
00124
00125