NetBurner 3.1
MockExpectedCall.h
1 /*
2  * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the <organization> nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef D_MockExpectedCall_h
29 #define D_MockExpectedCall_h
30 
31 class MockNamedValue;
32 
33 extern SimpleString StringFrom(const MockNamedValue& parameter);
34 
35 class MockExpectedCall
36 {
37 public:
38  MockExpectedCall();
39  virtual ~MockExpectedCall();
40 
41  virtual MockExpectedCall& withName(const SimpleString& name)=0;
42  virtual MockExpectedCall& withCallOrder(unsigned int)=0;
43  MockExpectedCall& withParameter(const SimpleString& name, bool value) { return withBoolParameter(name, value); }
44  MockExpectedCall& withParameter(const SimpleString& name, int value) { return withIntParameter(name, value); }
45  MockExpectedCall& withParameter(const SimpleString& name, unsigned int value) { return withUnsignedIntParameter(name, value); }
46  MockExpectedCall& withParameter(const SimpleString& name, long int value) { return withLongIntParameter(name, value); }
47  MockExpectedCall& withParameter(const SimpleString& name, unsigned long int value) { return withUnsignedLongIntParameter(name, value); }
48  MockExpectedCall& withParameter(const SimpleString& name, double value) { return withDoubleParameter(name, value); }
49  MockExpectedCall& withParameter(const SimpleString& name, const char* value) { return withStringParameter(name, value); }
50  MockExpectedCall& withParameter(const SimpleString& name, void* value) { return withPointerParameter(name, value); }
51  MockExpectedCall& withParameter(const SimpleString& name, const void* value) { return withConstPointerParameter(name, value); }
52  MockExpectedCall& withParameter(const SimpleString& name, void (*value)()) { return withFunctionPointerParameter(name, value); }
53  MockExpectedCall& withParameter(const SimpleString& name, const unsigned char* value, size_t size) { return withMemoryBufferParameter(name, value, size); }
54  virtual MockExpectedCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value)=0;
55  virtual MockExpectedCall& withOutputParameterReturning(const SimpleString& name, const void* value, size_t size)=0;
56  virtual MockExpectedCall& withOutputParameterOfTypeReturning(const SimpleString& typeName, const SimpleString& name, const void* value)=0;
57  virtual MockExpectedCall& ignoreOtherParameters()=0;
58 
59  virtual MockExpectedCall& withBoolParameter(const SimpleString& name, bool value)=0;
60  virtual MockExpectedCall& withIntParameter(const SimpleString& name, int value)=0;
61  virtual MockExpectedCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value)=0;
62  virtual MockExpectedCall& withLongIntParameter(const SimpleString& name, long int value)=0;
63  virtual MockExpectedCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value)=0;
64  virtual MockExpectedCall& withDoubleParameter(const SimpleString& name, double value)=0;
65  virtual MockExpectedCall& withStringParameter(const SimpleString& name, const char* value)=0;
66  virtual MockExpectedCall& withPointerParameter(const SimpleString& name, void* value)=0;
67  virtual MockExpectedCall& withFunctionPointerParameter(const SimpleString& name, void (*value)())=0;
68  virtual MockExpectedCall& withConstPointerParameter(const SimpleString& name, const void* value)=0;
69  virtual MockExpectedCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size)=0;
70  virtual MockExpectedCall& andReturnValue(bool value)=0;
71  virtual MockExpectedCall& andReturnValue(int value)=0;
72  virtual MockExpectedCall& andReturnValue(unsigned int value)=0;
73  virtual MockExpectedCall& andReturnValue(long int value)=0;
74  virtual MockExpectedCall& andReturnValue(unsigned long int value)=0;
75  virtual MockExpectedCall& andReturnValue(double value)=0;
76  virtual MockExpectedCall& andReturnValue(const char* value)=0;
77  virtual MockExpectedCall& andReturnValue(void* value)=0;
78  virtual MockExpectedCall& andReturnValue(const void* value)=0;
79  virtual MockExpectedCall& andReturnValue(void (*value)())=0;
80 
81  virtual MockExpectedCall& onObject(void* objectPtr)=0;
82 };
83 
84 #endif