Utils::CalitkoMocks::CallDriver< Function > Class Template Reference

#include <CallDriver.h> [code]

List of all members.


Detailed Description

template<typename Function>
class Utils::CalitkoMocks::CallDriver< Function >

A thin wrapper around BoundFunction.

A test driver class has the same functions as the class it is driving except the return values are substituted with CallDriver objects. These objects allow for the method chaining syntax to be used when modeling the object interactions in a test.

This class is used as a helper to build a tree of BoundFunction and ExpecedFunction objects and thus model an interaction between a object of the class being tested (represented by a test driver class) and its environment (represented by objects of mock classes). ExpectationDriver, as well as CallDriver and DelayedCallDriver manipulate the underlying BoundFunction and ExpectedFunction objects and their functions return objects or object references to each other depending on the context.

CallDriver objects are supposed to be created by the template factory method MockBase::call() for a BoundFunction. CallDriver's willCall() would create and return an ExpectationDriver object for an ExpectedFunction from a mock object. The context effectively changes and the user could set the properties of the ExpectedFunction over the interface of ExpectationDriver. To switch back to the context of CallDriver, ExpectationDriver::willReturn() should be called.

Definition at line 62 of file CallDriver.h.

Public Types

typedef Function::ReturnType ReturnType

Public Member Functions

 CallDriver (auto_ptr< Function > foo)
 CallDriver (const CallDriver &other)
 ~CallDriver ()
template<typename Foo>
ExpectationDriver< CallDriver,
ExpectedFunction< Foo > > 
willCall (ExpectationPair< ExpectedFunction< Foo > > expectation)
 Express the expectation that a function will be called.
template<typename Foo>
ExpectationDriver< CallDriver,
ExpectedFunction< Foo > > 
willCallMsg (ExpectationPair< ExpectedFunction< Foo > > expectation, const std::string &expressionString, const SourceLine &sourceLine)
void willReturn (const ReturnTypeWrapper< ReturnType > &returnValue)
 Express the expectation for the return value of the bound function.
void willReturnMsg (const ReturnTypeWrapper< ReturnType > &returnValue, const std::string &expressionString, const SourceLine &sourceLine)
void returns ()
 Express the expectation that the bound function returns void.
template<typename Foo>
CallDriverwillEmit (ExpectationPair< ExpectedFunction< Foo > > expectation)
 Express the expectation that a signal is emitted form bound function.
template<typename Foo>
CallDriverwillEmitMsg (ExpectationPair< ExpectedFunction< Foo > > expectation, const std::string &expressionString, const CPPUNIT_NS::SourceLine &sourceLine)

Private Attributes

auto_ptr< Function > f
bool throwing

Friends

class ExpectationDriver


Member Typedef Documentation

template<typename Function>
typedef Function::ReturnType Utils::CalitkoMocks::CallDriver< Function >::ReturnType
 

Definition at line 65 of file CallDriver.h.


Constructor & Destructor Documentation

template<typename Function>
Utils::CalitkoMocks::CallDriver< Function >::CallDriver auto_ptr< Function >  foo  )  [inline]
 

Definition at line 67 of file CallDriver.h.

template<typename Function>
Utils::CalitkoMocks::CallDriver< Function >::CallDriver const CallDriver< Function > &  other  )  [inline]
 

Definition at line 68 of file CallDriver.h.

template<typename Function>
Utils::CalitkoMocks::CallDriver< Function >::~CallDriver  )  [inline]
 

If we are owning a bound function will check whether it was called.

Note:
The dtor potentially throws an exception but only when we think it would be safe to do so, i.e. only if we are sure no exception has been thrown by ourselves. If an out of memory exception has been thrown, we could end up throwing an exception, which would cause terminate() to be called.
That call potentially throws but C++ guarantees all members are properly destroyed even when the dtor throws:

Definition at line 70 of file CallDriver.h.


Member Function Documentation

template<typename Function>
void Utils::CalitkoMocks::CallDriver< Function >::returns  )  [inline]
 

Express the expectation that the bound function returns void.

Definition at line 140 of file CallDriver.h.

template<typename Function>
template<typename Foo>
ExpectationDriver<CallDriver, ExpectedFunction <Foo> > Utils::CalitkoMocks::CallDriver< Function >::willCall ExpectationPair< ExpectedFunction< Foo > >  expectation  )  [inline]
 

Express the expectation that a function will be called.

This overload gets called when we want to model the expectation that a function of a mock object gets called.

Definition at line 93 of file CallDriver.h.

template<typename Function>
template<typename Foo>
ExpectationDriver<CallDriver, ExpectedFunction <Foo> > Utils::CalitkoMocks::CallDriver< Function >::willCallMsg ExpectationPair< ExpectedFunction< Foo > >  expectation,
const std::string &  expressionString,
const SourceLine &  sourceLine
[inline]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 107 of file CallDriver.h.

template<typename Function>
template<typename Foo>
CallDriver& Utils::CalitkoMocks::CallDriver< Function >::willEmit ExpectationPair< ExpectedFunction< Foo > >  expectation  )  [inline]
 

Express the expectation that a signal is emitted form bound function.

Definition at line 148 of file CallDriver.h.

template<typename Function>
template<typename Foo>
CallDriver& Utils::CalitkoMocks::CallDriver< Function >::willEmitMsg ExpectationPair< ExpectedFunction< Foo > >  expectation,
const std::string &  expressionString,
const CPPUNIT_NS::SourceLine &  sourceLine
[inline]
 

Definition at line 162 of file CallDriver.h.

template<typename Function>
void Utils::CalitkoMocks::CallDriver< Function >::willReturn const ReturnTypeWrapper< ReturnType > &  returnValue  )  [inline]
 

Express the expectation for the return value of the bound function.

Definition at line 116 of file CallDriver.h.

template<typename Function>
void Utils::CalitkoMocks::CallDriver< Function >::willReturnMsg const ReturnTypeWrapper< ReturnType > &  returnValue,
const std::string &  expressionString,
const SourceLine &  sourceLine
[inline]
 

Definition at line 131 of file CallDriver.h.


Friends And Related Function Documentation

template<typename Function>
friend class ExpectationDriver [friend]
 

Definition at line 174 of file CallDriver.h.


Member Data Documentation

template<typename Function>
auto_ptr<Function> Utils::CalitkoMocks::CallDriver< Function >::f [mutable, private]
 

Definition at line 171 of file CallDriver.h.

template<typename Function>
bool Utils::CalitkoMocks::CallDriver< Function >::throwing [private]
 

Definition at line 172 of file CallDriver.h.


The documentation for this class was generated from the following file: