Hi!
Typemock looks quite powerful and flexible, but due to lack of experience I cannot find easy way to treat the following problem.
Assume I have a method:
public Result DoUsefulThing(string s1, string s2, string s4, string s5)
{
var local1 = obj1.Get(s1);
if (!obj1.Check(local1))
return new Result("something undesirable");
var local2 = obj2.Get(s2);
if (!obj2.Check(local2))
return new Result("something quite bad");
var local3 = obj3.Get(s3);
if (!obj3.Check(local3))
return new Result("something very bad");
var local4 = obj4.Get(s4);
if (!obj4.Check(local4))
return new Result("something terrible");
var local5 = obj5.Get(s5);
if (!obj5.Check(local5))
return new Result("something horrible");
var value = this.Calculation(local1, local2, local3, local4, local5);
if (this.IsError(value))
return new Result("the last step resulted in an error!");
return new Result{ Value = value, Msg = "Success"};
}
It (i.e. method DoUsefulThing) depends on a number of various objects and making calls to their methods (objN.Get, objN.Check, this.Calculation, this.IsError).
The obj1..obj5 are created and correctly formed before the call to method DoUsefulThing (some created in constructor, some in other methods, some are passed from elsewhere).
What I want is to make a number of tests, where, say, calls to obj1, obj2, obj4, obj5 methods are remain original, but the result of the call to obj3.Get, obj3.Check and Calculation is substituted by my code. I suppose this is doable with Typemock framework, althoug I don't know how.
Could you explain me please, how do I achieve this? Thank you in advance!