In the example below FakeItEasy return 0
even though the IThing
member GetValue()
has not been defined. My question is; why is a value of 0
returned from an undefined member call and not an exception thrown; is there some general mocking/faking/stubbing framework software pattern that dictates that throwing exceptions for calling undefined members is a no-no?
public interface IThing
{
int GetValue();
}
public class Thing: IThing
{
public int GetValue()
{
return 1000;
}
}
[TestMethod]
public void Test1()
{
var thing= A.Fake<IThing>();
// A.CallTo(() => thing.GetValue()).Returns(1);
var val = thing.GetValue(); // Not defined but returns 0 rather than throwing an exeption
Assert.AreEqual(1, val);
}