Highlight out with wet or rhino or other

I tried with NMock2, but I get TypeLoadExceptions when I try to pass mocks to the constructor, I also saw that TypeMock can do this, but it costs $ 80

+5
source share
2 answers

I found out yourself, you can do it with Moq, like this:

var info = new Info { stuff = 1 };

textReader.Setup(o => o.Read<CandidateCsv>("", out info));

what he:)

+7
source

Moq does not support bullying / ref parameters, but you can do this using Rhino Mocks, using OutRef, which takes one argument for each out / ref parameter to a 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);
+3
source

All Articles