Just assign the out or ref parameter from the test.
Given this interface:
public interface ILegacy { bool Foo(out string bar); }
You can write a test as follows:
[TestMethod] public void Test13() { string bar = "ploeh"; var legacyStub = new Mock<ILegacy>(); legacyStub.Setup(l => l.Foo(out bar)) .Returns(true); Assert.IsTrue(legacyStub.Object.Foo(out bar)); Assert.AreEqual("ploeh", bar); }
Mark seemann
source share