我嘗試使用MoqMockingKernel類。 (Ninject.MockingKernel.Moq)從Ninject.MockingKernel Extension進行單元測試。MoqMockingKernel:System.TypeLoadException:違反類型的繼承安全規則
在初始化MoqMockingKernel,我發現了以下錯誤:
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..
我的初始化代碼:
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 };
}
我怎樣才能解決這個TypeLoadException
?