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);






