I tried with NMock2 but I get TypeLoadExceptions when trying to pass the mocks into the constructor, also I saw TypeMock can do that but it costs 80$
I found out myself, you can actually do that with Moq, it's like this:
var info = new Info { stuff = 1 };
textReader.Setup(o => o.Read<CandidateCsv>("", out info));
that's it :)
Moq does not support mocking out/ref parameters, but you can do it using Rhino Mocks using OutRef, which accepts one argument for each out/ref parameter in the method.
MockRepository mockRepository = new MockRepository();
// IService.Execute(out int result);
var mock = mockRepository.CreateStub<IService>();
int mockResult; // Still needed in order for Execute to compile
mock.Setup(x => x.Execute(out mockResult)).OutRef(5);
mock.Replay();
int result;
mock.Execute(out result);
Assert.AreEqual(5, result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With