我有一个引用FluentAssertions的单元测试项目,当我更新到版本3时出现错误

Bra*_*ath 6 fluent-assertions

我有一个.net 4.0测试项目,它为Should()扩展方法抛出了一个找不到异常的方法.

然后我注意到它也为int类型抛出异常.

有人知道FluentAssertions V3为什么会这样吗?

现在我要回到我的2.2版本.

作为参考,这是FluentAssersions项目网站https://github.com/dennisdoomen/fluentassertions/releases

这是代码示例: 在此输入图像描述

var actualItems = new List<string> { "" };
actualItems.All(i => i == "X").Should().BeTrue("All items should be X") ;
Run Code Online (Sandbox Code Playgroud)

这是一个例外:

Error   237 'bool' does not contain a definition for 'Should' 
and no extension method 'Should' accepting a first argument of type 'bool' 
could be found (are you missing a using directive or an assembly reference?)
C:\pathtoproject\Tests.cs
Run Code Online (Sandbox Code Playgroud)

Den*_*men 8

那是因为v3.0需要.NET 4.0.3用于测试项目.这是Portable Class Libraries支持的最早版本.这有点令人困惑,但如果您已经安装了.NET 4.5,那么您已经在使用4.0.3了.我已更新发行说明.

  • 上周末我们发布了v3.1,它解决了上述问题.我们现在再次支持普通的旧.NET 4.0. (2认同)