Hi
I checked it out and you are right, indeed we have a bug in reflective mock API :evil:
However I can offer you two workarounds:
The best solution is to use our new Arrange Act Assert API
Here is an example of the same test with AAA API:
[TestMethod]
public void NullableDoInstead()
{
var fake = Isolate.Fake.Instance<Stockage>();
// this line replaces the DynamicReturnValue in the reflective mocks API
Isolate.WhenCalled(() => fake.Prop).DoInstead(context => { return null; });
Isolate.Swap.NextInstance<Stockage>().With(fake);
Stockage stock = new Stockage();
bool? result = stock.Method();
Assert.IsNull(result);
}
If for some reason you can't use the AAA API, here is an example using natural mocks API:
[TestMethod]
public void NullableNaturalMocks()
{
using (var rec = RecorderManager.StartRecording())
{
Stockage mock = new Stockage();
var dum = mock.Prop;
rec.Return(new DynamicReturnValue(
delegate(Object[] parameters, Object context)
{
return null;
}
));
}
Stockage stock = new Stockage();
Assert.IsNull(stock.Method());
}
Hope it helps.