问题
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 @>
Under NUnit I get this exception:
FsTest.Tests.Example.foo: System.MissingMethodException : Method not found: 'System.Tuple
2<Microsoft.FSharp.Collections.FSharpList
1,Microsoft.FSharp.Quotations.FSharpExpr> Internal.reduceFullyAndGetLast(Microsoft.FSharp.Quotations.FSharpExpr)'.
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.
回答1:
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>
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?
Unfortunately, I don't have VS2012 installed and so I am somewhat crippled in my ability to really diagnose this issue for you.
来源:https://stackoverflow.com/questions/13846561/missingmethodexception-when-using-unquote-asserts