我正在尝试设置Moles以用于我们的单元测试.我们正在使用xunit,所以我使用的是带有moles的Xunit扩展(Microsoft.Moles.Framework.Xunit).但是,当我们运行Xunit 1.7时,Moles抱怨我没有运行版本1.6.1.1521(带有FileLoadException).
Moles Manual(第28页)确实说:
xUnit.net Version:
1.5.0.1479 (for other xUnit.net versions,recompile the attribute from sources)
这就是我被卡住的地方 – 这个xunit扩展的源代码是在哪里可用的?或者我是否必须使用Moles要求的特定版本的xunit?
解决方法
你不能在moles.runner.exe.config中定义程序集绑定重定向吗?
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="xunit.dll" publicKeyToken="8d05b1bb7a6fdb6c" /> <bindingRedirect oldVersion="1.5.0.1479" newVersion="1.6.1.1521" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>