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

标签 fluent-assertions

我有一个 .net 4.0 测试项目,它抛出了 的方法未找到异常应该()扩展方法。

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

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

现在我要回到我的 2.2 版。

供引用,这是 FluentAssersions 项目网站 https://github.com/dennisdoomen/fluentassertions/releases

这是代码示例:
enter image description here

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/

相关文章:

c# - 更新到最新的 FluentAssertions 破坏了我的单元测试

c# - 如何使用 FluentAssertions 编写 CustomAssertion?

c# - 流利的断言 : How to break through drill-down of Which/And cascades?

c# - 如何使用流畅的断言比较对象图中的嵌套列表

c# - 设置 ExclusionNestedObjects 时,FluentAssertions 导致 ObjectDisposeException

c# - 流畅的断言 : Be() vs Equals()

c# - 使用 ShouldBeEquivalentTo 时如何排除 IEnumerable 中所有项目的属性?

c# - 如何用 FluentAssertions 替换 Assert.Fail()

c# - 流畅的断言 ShouldAllBeEquivalentTo

c# - FluentAssertions - Should().BeEquivalentTo() 当属性属于不同类型时