我有一个方法,它有一个out参数,它返回许多记录。我想知道如何用FakeItEasy模拟它。
发布于 2011-03-31 15:07:02
您应该使用.AssignsOutAndRefParameters配置方法:
[Test]
public void Output_and_reference_parameters_can_be_configured()
{
var fake = A.Fake<IDictionary<string, string>>();
string ignored = null;
A.CallTo(() => fake.TryGetValue("test", out ignored))
.Returns(true)
.AssignsOutAndRefParameters("foo");
// This would of course be within you SUT.
string outputValue = null;
fake.TryGetValue("test", out outputValue);
Assert.That(outputValue, Is.EqualTo("foo"));
}https://stackoverflow.com/questions/5492742
复制相似问题