Interested in a
Personal Demo ?


Name* :
Please Enter your Name
Company E–Mail* :
Please Enter a Valid Email

Testimonials


"Typemock Isolator enables us to modify our legacy applications without changing the source code."
Christian Mérat, .NET Architect & Developer, GSoft Group
Success stories

PurchaseOptions


US Toll Free
866–895–4680
Outside US
+44–203–150–0293
Get your printable quote
Buy online

 Main | How to change behavior with Isolator++ »

Asserting A Function Call

With Isolator++ you can assert a function call on a fake object. Let’s say my class has a void call and I want to make sure got called. In the next test, the ASSERT_WAS_CALLED macro is used for validation of the VoidCall call:

// Asserting a method call

TEST_F(IsolatorTests, AssertWasCalled)

{

     ConcreteClass* fakeConcrete = FAKE(ConcreteClass);

     fakeConcrete->VoidCall(); // this call is ignored

     ASSERT_WAS_CALLED(fakeConcrete->VoidCall());

} 

 


The test will fail if the method was not called during the run. To make sure a method was not called, use ASSERT_ NOT_CALLED macro:
ASSERT_NOT_CALLED(fakeConcrete->VoidCall());

And finally to verify a method was called X times use the TIMES_CALLED macro:
int num = TIMES_CALLED(instance-> VoidCall ());

On the num variable, you can now use ASSERT_EQ to verify the count):
ASSERT_EQ(3, num);