【发布时间】:2014-10-20 14:59:48
【问题描述】:
在 NSubstitute 中,是否可以指定在 Received 失败时应该抛出的消息?类似于以下内容:
[Test]
public void Should_execute_command()
{
var command = Substitute.For<ICommand>();
var something = new SomethingThatNeedsACommand(command);
something.DoSomething();
command.Received()
.Execute()
.Because("We should have executed the command that was passed in");
}
为了比较,在起订量中,您可以这样做:
command.Verify(c => c.Execute, "We should have executed the command that was passed in");
然后您会在测试运行程序中将该消息作为测试失败消息的一部分。这有助于使测试失败更容易阅读/诊断。 NSubstitute 有类似的吗?
【问题讨论】:
标签: c# nsubstitute