1
在NSubstitute中,是否可以指定在接收失敗時應該拋出的消息?像下面這樣:NSubstitute的失敗消息。接收到的調用
[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中有類似的東西嗎?