It appears that the following code doesn't behave as I would expect:
using FakeItEasy;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var derived = A.Fake<IDerived>();
A.CallTo(() => derived.Dependency).Returns(null);
IBase baseObj = derived;
Assert.IsNull(baseObj.Dependency); //Fails
}
}
public interface IDerived : IBase
{
new IDependency Dependency { get; }
}
public interface IBase
{
IDependency Dependency { get; }
}
public interface IDependency
{
}
Instead of returning null, fake it easy returns a fake instance of IDependency
. Perhaps by design? Anyway, how would I go around this problem and ensure baseObj.Dependency
returns what was configured?