我有一个 .net 4.0 测试项目,它抛出了 的方法未找到异常应该()扩展方法。
然后我注意到它也为 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") ;
这里有一个异常(exception):
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
最佳答案
这是因为 v3.0 需要 .NET 4.0.3 用于您的测试项目。这是可移植类库支持的最早版本。这有点令人困惑,但如果您已经安装了 .NET 4.5,那么您已经在使用 4.0.3。我已经更新了发行说明。
关于fluent-assertions - 我有一个引用 FluentAssertions 的单元测试项目,当我更新到版本 3 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23371910/