unit-testingninjecttypemocktypemock-isolator

Running Unit Test having Operation could destablize the runtime exception at new StandardKernel


In our unit tests where it first load db setting from a singleton class, we have:

IKernel kernel = new StandardKernel(new OurInfrastructureNinjectModule());
_myService = kernel.Get<MyService>(); // To inject a concrete to myService

It runs fine in our mvc application, however, exception threw when it is called by unit tests.


Solution

  • Note: I work at Typemock

    Due to changes in security in .NET 4, there was a bug in Typemock Isolator where code running from assemblies marked with AllowPartiallyTrustedCallers (APTCA) or SecurityTransparent attributes would crash with this exception. Ninject, seems like it, is marked with such an attribute.

    We had fixed this issue in the latest version, so please download it at http://www.typemock.com.

    If your issue persists in the latest version (6.0.9 currently), please contact us via support at typemock.com