I use NSubstitute v1.7.1.0 and AutoFixture.AutoNSubstitute v3.16.5. Obviously AutoFixture was compiled against an older version of NSubsitute.
In a test I get the exception:
System.IO.FileNotFoundException : Could not load file or assembly 'NSubstitute,
Version=1.4.3.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca' or one of its
dependencies. The system cannot find the file specified.
So I added a binding redirect to my test project (as suggested here):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NSubstitute" publicKeyToken="92dd2e9066daa5ca" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.7.1.0" newVersion="1.7.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Still getting the exception. What am I doing wrong?
EDIT :
The problem disappears when I use AutoFixture for creating an instance of a class instead of an interface (myFixture.Create<MyClass>()
instead of myFixture.Create<MyInterface>()
).