Using NUnit 2.6.4 & FakeItEasy 1.25.2 to unit test a C# code in Visual Studio 2013 Community Edition
The following test fragment executes as expected
[Test]
public void test_whatIsUpWithStreamRead()
{
Stream fakeStream = A.Fake<Stream>();
byte[] buffer = new byte[16];
int numBytesRead = fakeStream.Read(buffer, 0, 16);
Assert.AreEqual(0, numBytesRead);
}
however as soon as I decorate my fake with a CallTo/Returns() or ReturnsLazily() statement...
[Test]
public void test_whatIsUpWithStreamRead()
{
Stream fakeStream = A.Fake<Stream>();
A.CallTo(() => fakeStream.Read(A<byte[]>.Ignored, A<int>.Ignored, A<int>.Ignored)).Returns(1);
byte[] buffer = new byte[16];
int numBytesRead = fakeStream.Read(buffer, 0, 16);
Assert.AreEqual(1, numBytesRead);
}
fakeStream.Read()
throws a System.InvalidOperationException with the message:
"The number of values for out and ref parameters specified does not match the number of out and ref parameters in the call."
from within FakeItEasy.Configuration.BuildableCallRule.ApplyOutAndRefParametersValueProducer(IInterceptedFakeObjectCall fakeObjectCall)
, which seems pretty odd to me as Stream.Read()
doesn't have any out/ref parameters.
Is this a bug that I should be reporting at https://github.com/FakeItEasy, or am I missing something?
thx