使用Unquote断言时缺少MissingMethodException [英] MissingMethodException when using Unquote asserts

查看:178
本文介绍了使用Unquote断言时缺少MissingMethodException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用取消引用,并将NUnit用作测试运行程序.该测试用例取自入门,并且可以在NUnit之外运行时按预期工作:

I'm trying to use unquote with NUnit as the test runner. The test case is taken from Getting Started and works as expected when run outside of NUnit:

namespace FsTest.Tests

open NUnit.Framework
open Swensen.Unquote

[<TestFixture>]
module Example =

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

在NUnit下,我得到此异常:

Under NUnit I get this exception:

FsTest.Tests.Example.foo:System.MissingMethodException:方法不正确 成立: 'System.Tuple 2<Microsoft.FSharp.Collections.FSharpList 1,Microsoft.FSharp.Quotations.FSharpExpr> Internal.reduceFullyAndGetLast(Microsoft.FSharp.Quotations.FSharpExpr)'.

FsTest.Tests.Example.foo: System.MissingMethodException : Method not found: 'System.Tuple2<Microsoft.FSharp.Collections.FSharpList1,Microsoft.FSharp.Quotations.FSharpExpr> Internal.reduceFullyAndGetLast(Microsoft.FSharp.Quotations.FSharpExpr)'.

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

I'd like to know if there's anything wrong with the code above and how I could make it work. Unquote's raise fail for me in the same way if that helps.

推荐答案

基于对问题的描述,我怀疑您需要使用FSharp.Core绑定重定向(从版本4.0.0.0到版本4.3)配置NUnit项目. 0.0是因为最新版本的Unquote是针对.NET 4.0构建的,而您的测试项目则针对.NET 4.5.

Based on the description of your problem, I suspect you need to configure your NUnit project with an FSharp.Core binding redirect from version 4.0.0.0 to version 4.3.0.0 since the latest version of Unquote is built for .NET 4.0 and your test project targets .NET 4.5.

有关详细信息,请参见取消报价问题.我相信您的配置看起来像

See this Unquote issue for details. I believe your configuration would look something like

<?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项目您需要将其确切放置在什么地方,但是可能是通过

I'm not sure exactly where you would need to put this for an NUnit project, but maybe in the config file specified through the Project Editor?

不幸的是,我没有安装VS2012,因此我无法为您真正诊断此问题.

Unfortunately, I don't have VS2012 installed and so I am somewhat crippled in my ability to really diagnose this issue for you.

这篇关于使用Unquote断言时缺少MissingMethodException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆