I have a class library with the following interface:
public interface IFoo
{
void Foo(Claim claim);
}
I have a unit test project with the following test:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var stubIFoo = new ClassLibrary1.Fakes.StubIFoo();
}
}
If both projects are targeting .NET Framework 4.6 everything works fine. But, if both projects are targeting .NET Framework 4.5.1, I get the following warning:
Cannot generate stub for ClassLibrary1.IFoo: method System.Void ClassLibrary1.IFoo.Foo(System.Security.Claims.Claim claim) unstubbable: method is abstract and could not be stubbed, type System.Security.Claims.Claim is not available in the target framework version.
And a compilation error because StubIFoo
is not generated anymore:
The type or namespace name 'StubIFoo' does not exist in the namespace 'ClassLibrary1.Fakes' (are you missing an assembly reference?)
This is the contents of the ClassLibrary1.fakes
file:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true" Verbosity="Verbose">
<Assembly Name="ClassLibrary1"/>
<ShimGeneration>
<Remove TypeName="IFoo"/>
<Remove TypeName="IBar"/>
</ShimGeneration>
</Fakes>
Do you have any ideea about how can I make this work when both projects target .NET Framework 4.5.1 ?