Hello,
I want to use the FAKE_ALL to fake all my objects of the same class. I modified the example from the documentation of DoInstead:
class Person
{
public:
int GetAverageAge() { return 0; }
};
class AltPerson
{
public:
int ISOLATOR_TESTABLE ReturnAnotherAge()
{
return 10;
}
};
I use FAKE_ALL to fake all future instances of Person in this way:
Person* livePerson = FAKE_ALL<Person>();
AltPerson* altPerson = new AltPerson();
WHEN_CALLED(livePerson->GetAverageAge()).DoMemberFunctionInstead(altPerson, ReturnAnotherAge);
Person *realPerson = new Person();
ASSERT_EQ(10, realPerson->GetAverageAge());
ISOLATOR_CLEANUP();
Unfortuantely the original method of Person is used which returns 0.
Am I using this in the wrong way or is something else not correct?
I use Windows 10 and google test.
Thanks a lot in advance,
Michaela