I have problem with faking my class:
Class A has a method:
protected virtual int method(int argument)
{
implementation
return int;
}
Class B extends class A and overrides the method:
protected override int method(int argument)
{
int result = base.method(argument);
implementation
return result + 1;
}
I need to mock class B and test the method function. The problem is that I need to avoid calling the base.method(argument) function. I just need to test my method implementation, and mock that function to return an int.
How can I do it with FakeItEasy? Or other mocking frameworks?
UPDATE
Problem solved by:
making function:
int MethodCaller(int argument)
{
base.method(argument);
}
and executing it in my class B “method” function. Than mocking MethodCaller function
You can do it with helper class + one more helper method, but I realy don’t like this solution:
so in test you can call
new C().Result(10)