【发布时间】:2020-02-21 15:06:00
【问题描述】:
我正在研究使用FluentAssertions-4.8.0 的更大解决方案。
由于我目前没有时间升级到最新版本(撰写本文时为 5.9.0),我想知道如何在上述版本中声明异常。
我知道它在 5.x 中是如何完成的,但我如何在 4.x 中断言异常?
[Fact]
public void Should_Throw_InvalidOperationException_If_...()
{
// Arrange
var resolver = new SomeResolver();
var foo = new Foo();
Action act = () => resolver.DoSomething(foo);
// Act & Assert
act.Should().Throw<InvalidOperationException>.WithMessage("...");
}
【问题讨论】:
标签: c# exception xunit fluent-assertions