FsUnit.xUnit FSharp.Core和xunit.assert程序集绑定

时间:2017-10-03 10:55:35

标签: f# nuget xunit fsunit

我正在使用F#迈出第一步,并使用FsUnit.xUnit进行测试。 在Visual Studio 2017中,我设置了一个全新的F#项目并添加了一个测试项目。 到测试项目我NuGet FsUnit.xUnit 3.0.0然后NuGet FsUnit.xUnit.Sample。 一切都在建立。 然后测试失败

System.IO.FileLoadException
Could not load file or assembly 'FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at ApplicationLibraryTest.Tests.Given a LightBulb that has had its state set to true.when I ask whether it is On it answers true.()

在阅读FsUnit HomepageFsUnit Issues后,我添加app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.4.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

由于bin/debug中的FSharp.Core.dll是版本4.4.1.0。

再次运行测试

System.IO.FileLoadException
Could not load file or assembly 'xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at ApplicationLibraryTest.Tests.Given a LightBulb that has had its state set to true.when I ask whether it is On it answers true.() in D:\git\ApplicationLibrary\ApplicationLibraryTest\FsUnitSample.fs:line 18

所以我在app.config中添加了另一个重定向,如下所示

  <dependentAssembly>
    <assemblyIdentity name="xunit.assert" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.2.0.0" />
  </dependentAssembly>

2.2.0.0版是我在bin\debug中找到的xunit.assert的版本。

然而,测试再次失败。这次是

System.IO.FileLoadException
Could not load file or assembly 'xunit.assert, Version=2.2.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at ApplicationLibraryTest.Tests.Given a LightBulb that has had its state set to true.when I ask whether it is On it answers true.() in D:\git\ApplicationLibrary\ApplicationLibraryTest\FsUnitSample.fs:line 18

System.IO.FileLoadException
Could not load file or assembly 'xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. 
(Exception from HRESULT: 0x80131040)
  Exception doesn't have a stacktrace

测试项目详情: 目标F#运行时:4.4.1.0

目标框架:4.6.2

我做错了什么?这是一个配置问题还是我错过了阻止FsUnit.xUnit运行测试的东西?

0 个答案:

没有答案