I'm hitting a null reference exception in my arrange calls.
Am I doing something wrong or have I found a bug?
I think the issue may be with WithExactArguments()?
Here's a sample project that demos the issue:
public interface ISearch2
{
string GetString(int type);
string GetFromGuid(Guid g);
}
public interface IProvision
{
ISearch2 Search { get; }
}
public abstract class BaseClass2
{
protected string GetFromGuid(IProvision p, Guid g)
{
return p.Search.GetFromGuid(g);
}
}
[TestClass]
public class UnitTest2
{
[TestMethod]
public void UnderTest_Scenerio_Behaviour()
{
var mockInterface = Isolate.Fake.Instance<IProvision>();
Guid myGuid = new Guid("{817B3757-F836-478B-B327-77501F8182EA}");
Guid myGuid2 = new Guid("{8B4964BB-B6D8-4930-B38F-C32482E1FFBD}");
Isolate.WhenCalled(() => mockInterface.Search.GetFromGuid(myGuid)).WithExactArguments().WillReturn("one");
Isolate.WhenCalled(() => mockInterface.Search.GetFromGuid(myGuid2)).WithExactArguments().WillReturn("two"); //XXX this throws a null reference!!
var mockBase = Isolate.Fake.Instance<BaseClass2>();
Isolate.NonPublic.WhenCalled(mockBase, "GetFromGuid").CallOriginal();
string s = Isolate.Invoke.Method(mockBase, "GetFromGuid", mockInterface, myGuid) as string;
Isolate.Verify.WasCalledWithExactArguments(() => mockInterface.Search.GetFromGuid(myGuid));
Assert.IsNotNull(s);
Assert.AreEqual(s, "one");
}