I try to use the MoqMockingKernel class. (Ninject.MockingKernel.Moq) from the Ninject.MockingKernel Extension for a unit test.
At initializing the MoqMockingKernel I'm getting the following error:
System.TypeLoadException: System.TypeLoadException: Inheritance security rules violated by type: 'Ninject.MockingKernel.MockingKernel'. Derived types must either match the security accessibility of the base type or be less accessible..
My initializing code:
private MoqMockingKernel mockingKernel;
private Mock<IUnitOfWork> unitOfWorkMock;
private IExternalServiceRepository externalServiceRepository;
[TestInitialize]
public void Initialize()
{
this.mockingKernel = new MoqMockingKernel();
this.mockingKernel.Bind<IUnitOfWork>().ToMock();
this.unitOfWorkMock = this.mockingKernel.GetMock<IUnitOfWork>();
externalServiceRepository = new ExternalServiceRepository { Kernel = this.mockingKernel };
}
How can I solve this TypeLoadException
?