5

我正在尝试使用带有 NUnit 的unquote作为测试运行器。测试用例取自Getting Started并在 NUnit 之外运行时按预期工作:

namespace FsTest.Tests

open NUnit.Framework
open Swensen.Unquote

[<TestFixture>]
module Example =

    [<Test>]
    let foo() = 
        test <@ (1+2)/3 = 1 @>

在 NUnit 下我得到这个异常:

FsTest.Tests.Example.foo:System.MissingMethodException:找不到方法:'System.Tuple 2<Microsoft.FSharp.Collections.FSharpList1,Microsoft.FSharp.Quotations.FSharpExpr> Internal.reduceFullyAndGetLast(Microsoft.FSharp.Quotations.FSharpExpr)'。

我想知道上面的代码是否有问题以及如何使它工作。如果有帮助的话, Unquoteraise也会以同样的方式失败。

4

1 回答 1

8

根据您对问题的描述,我怀疑您需要使用FSharp.Core从版本 4.0.0.0 到版本 4.3.0.0 的绑定重定向来配置您的 NUnit 项目,因为最新版本的 Unquote 是为 .NET 4.0 构建的,并且您的测试项目的目标是 .NET 4.5.

有关详细信息,请参阅取消引用问题。我相信您的配置看起来像

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

我不确定您需要将它放在 NUnit 项目的确切位置,但可能在通过项目编辑器指定的配置文件中?

不幸的是,我没有安装 VS2012,所以我无法真正为您诊断这个问题。

于 2012-12-12T19:49:06.630 回答