4

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.

BrettJ
  • 980
  • 8
  • 15
  • I've checked several more ASP.NET web projects of ours (~1000 unit tests per app), and this appears to be the only stub that the VS2015 fakes generator is having a problem with in our code base. For now, I've implemented a TestDouble class which alleviates the need for this particular stub. But its still annoying, and no idea if we'll run into other problems. – BrettJ Jul 23 '15 at 20:47
  • I am seeing the same issue with Stubs that return MemoryStream. The issue is since Visual Studio 2013 Update 5 – Ali Aug 19 '15 at 12:30
  • I'm having exactly the same problem. We have an issue with ClaimsIdentity and MemoryStream – Jan Saris Sep 16 '15 at 08:02
  • Just wanted to follow up; we've encountered no other stubs that had this problem. – BrettJ Apr 20 '16 at 13:46
  • We've encountered the same problem with ClaimsIdentity. Follow up. – Roy Liu Nov 29 '16 at 01:55

0 Answers0