Deep Chaining |
Top Previous Next |
Isolator++ Professional allows you to fake a chain of members called in one command.
Note: Deep Chaining also supports Conditional Behavior Faking
When you use Deep Chaining every method in the chain gets mocked and their behavior is set to default, or if the method is void it will be set to be ignored.
Example
In the following example the GetLocation method is being set to return a fake GPSLocation even if it's not literally faked in the test. And when the chain gets called in the GetLocationLatitude method it will return the value we set it to return.
TEST_F(Examples, SettingChainedMethodsBehavior) { Person* p = new Person();
Address * fakeAdd = FAKE<Address>();
WHEN_CALLED(fakeAdd->GetLocation()->Latitude()).Return(10);
ASSERT_EQ(10, p->GetLocationLatitude(fakeAdd)); }
//The method under test
int Person::GetLocationLatitude(Address* pAddress) { return pAddress->GetLocation()->Latitude(); } |
Copyright Typemock Ltd. 2009-2025. All Rights Reserved.