如果我下载 FluentAssertions 1.7.1(我的所有单元测试当前都是针对它编写的),那么我可以引用该 dll,并且下面的测试将正常工作。
但我尝试通过 NuGet 并使用 FluentAssertions 版本 3.0.90 进行升级,还尝试了 3.0.107。遇到问题后,我尝试创建一个全新的解决方案/类库项目,但它无法从库中检测到任何内容...
下面的测试将无法编译,因为 .Should
找不到 bool
的扩展方法...或任何其他与此相关的事情。 但我可以清楚地看到它存在于对象浏览器中 我可以在程序集引用中看到 FluentAssertions 和 FluentAssertions.Core,但只能查看对象浏览器中的 >FluentAssertions.Core。 Intellisence 似乎为扩展方法找到的唯一东西是 .ShouldRaisePropertyChangeFor<...>
和.ShouldNotRaisePropertyChangeFor<...>
。
我的项目目标是.Net4.0,此时我认为这是一个配置问题,但我不确定从哪里开始寻找是否是这样。 Google 上似乎没有其他人遇到此问题。
using System;
using FluentAssertions;
using NUnit.Framework;
namespace IntegrationTests.CommonTests
{
[TestFixture]
public class _BasicTemplate_Tests
{
[Test]
public void Run_Basic_Test()
{
true.Should().Be(true);
}
}
}
最佳答案
那是因为 v3.0 需要 4.0.3 of the .NET框架(大多数人已经在使用)。
关于c# - FluentAssertions 引用未正确导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23417583/