I have an interface in a .NET 4.5 (not 4.6) class library,
public interface IBrokenFakeInterface
{
Claim WhyWontItGenerateFakeOfThisInterface();
}
In my unit test project (MSTest) when I have added the Fakes for the appropriate assembly containing this interface, I get compiler warning that says it cannot generate the stub.
Warning: Cannot generate stub for ClassLibrary1.IBrokenFakeInterface: method System.Security.Claims.Claim ClassLibrary1.IBrokenFakeInterface.WhyWontItGenerateFakeOfThisInterface() unstubbable: method is abstract and could not be stubbed, type System.Security.Claims.Claim is not available in the target framework version. ClassLibrary1Tests C:\Users\jacobsonba\Documents\Visual Studio 2015\Projects_tempFakeFiguringOut\ClassLibrary1Tests\Fakes\ClassLibrary1.fakes
While this is only a compiler warning, it results in compiler errors when a Unit Test project relies on StubIBrokenFakeInterface, because the Stub concrete type is not being created by the fakes generator.
Does anyone know the cause of this error, and a resolution? Changing the projects to be .NET 4.6 resolves it, but thats not a reasonable option for these projects for us. The exact same code compiles just fine in VS2013; in fact, if its compiled with VS2013, then open the solution in VS2015, it continues to work until the Fakes assembly is regenerated. So its obviously a problem in the fake generator that VS2015 is using.