How can I fake a result from a function called in another function? Normally Test2 will be a DataAccess method, which I do not like to receive real data. What I like, my unittest for testing is the business logic.
This is what I have now, but not working at all. The amount is always approved as 5!
public int Test1()
{
var value = this.Test2();
var businesslogic = value + 10;
return businesslogic;
}
public int Test2()
{
return 10;
}
Then I have Unittest, which I would like to run in my "business logic".
[TestMethod()]
public void TestToTest()
{
var instance = A.Fake<IClassWithMethods>();
A.CallTo(() => instance.Test2()).Returns(5);
var sum = instance.Test1();
Assert.AreEqual(15, sum);
}
source
share