Based on the code sample you provided, no!
The mocking library you mention is to provide fake data classes so your test cases don't depend on the status and availability of e.g. a database. The don't interact with the program flow.
It's purpose is to ease testing by allowing the developer to create mock implementations of custom objects and verify the interactions using unit testing. Source
So if you want your tests to mock the behavior of MyMethodToIgnore
, you need to change the source code to make the MyMethod
pure (so that it doesn't depend on intermediate results.
One possibility would be to add another method to the class, like this: (I'm using var
and dynamic
since you haven't given any implementation details yet.)
public void MyMethod()
{
var n = MyMethodToIgnore(sample);
MyTestedMethod(n);
}
public void MyTestedMethod(dynamic n) {
// do the calculation
}
This way, you can override/mock the behavior of the MyMethodToIgnore
and use mocked results to test your MyTestedMethod
.