Faking static methods |
Top Previous Next |
With Isolator++ Professional, you use the same syntax for changing the behavior of any methods, including static method calls.
Let's say we want to change the behavior of a static method:
class MyClass { public static int GetResult() { return -1; } ...
To change the behavior of GetResult, for example to return another value, say 10, you'd write the following:
WHEN_CALLED(MyClass::GetResult()).Return(10);
We used the regular WHEN_CALLED API to declare the behavior we want, this time with the static signature of the method. In this case, we're returning 10.
We could also declare that all public static calls of MyClass are faked and return default values, using the FAKE_STATICS API:
FAKE_STATICS<MyClass>();
Change the behavior of a private static method |
Copyright Typemock Ltd. 2009-2025. All Rights Reserved.