Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining Deep Chaining

Deep Chaining

Top  Previous  Next

Isolator++ Professional allows you to fake a chain of called in one command.
This is useful when the API you want to fake has several objects that return each other and this allows you to do this is one go and not to create multiple fakes.

 

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 get 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-2020.  All Rights Reserved.