.net Ninject:System.Security.VerificationException:操作可能会使运行时不稳定

.net Ninject:System.Security.VerificationException:操作可能会使运行时不稳定,.net,nunit,ninject,code-coverage,sharpdevelop,.net,Nunit,Ninject,Code Coverage,Sharpdevelop,我有下面的代码,在执行测试时运行良好 但是我尝试运行这些测试+代码覆盖率计算(SharpDevelop 4) 它抛出异常 有人能描述一下为什么会发生这种情况吗 设置:System.Security.VerificationException:无法执行操作 使运行时不稳定 [TestFixture] 公共类NinjectExamplesTest { 私有接口IExampleInterface { } 私有类ExampleInterface实现:IEExampleInterface { } 私有类示

我有下面的代码,在执行测试时运行良好

但是我尝试运行这些测试+代码覆盖率计算(SharpDevelop 4) 它抛出异常

有人能描述一下为什么会发生这种情况吗

设置:System.Security.VerificationException:无法执行操作 使运行时不稳定

[TestFixture]
公共类NinjectExamplesTest
{
私有接口IExampleInterface
{
}
私有类ExampleInterface实现:IEExampleInterface
{
}
私有类示例类
{
[注入]
公共IExampleInterface示例属性{get;set;}
}      
IKernel核;
[设置]
公共void Init()
{
内核=新的标准内核();
kernel.Bind().To();
}
[测试]
公共void TestStandardResolving()
{ 
//设置
//生意
var result=kernel.Get();
//核实
result.Should().NotBeNull();
result.Should().BeOfType();
}
[测试]
public void TestPropertyResolving()
{
//设置
var exampleClass=新的exampleClass();
//生意
Inject(exampleClass);
//核实
exampleClass.ExampleProperty.Should().NotBeNull();
exampleClass.ExampleProperty.Should().BeOfType();
}
}
用于完成代码覆盖。当使用或类似的程序集运行时,这看起来可能与(请参见结尾)有关


该修复程序应包含在最新的维护版本中,但我不知道SharpDevelop是否已打包了最新版本。

您真的要测试Ninject吗?!我只是想开始使用它,而不是Unity:),不幸的是,我开始收到这个异常。你真的应该对自己的代码进行单元测试,而不是第三方工具。为什么不测试您使用的技术(asp.net、winforms、webforms、entity framework等)或整个.net framework呢?如果您查看,您可以看到源代码已经包含测试。@archil使用集成测试发现第三方接口是非常常见的。不用担心-其他答案(批评您的测试方法)应该是注释。实际上,我使用Unity和Moq为我的测试创建了一个自动模拟容器——所以我和我的同事也这么做了。在测试方面,我们都有自己的偏好……今年我还将尝试添加到SharpDevelop中,因为它有分支覆盖支持,并且是正在积极开发的。
  [TestFixture]
  public class NinjectExamplesTest
  {
    private interface IExampleInterface
    {

    }

    private class ExampleInterfaceImplementation : IExampleInterface
    {

    }

    private class ExampleClass
    {
      [Inject]
      public IExampleInterface ExampleProperty { get; set; }
    }      

    IKernel kernel;   

    [SetUp]
    public void Init()
    {
      kernel = new StandardKernel();
      kernel.Bind<IExampleInterface>().To<ExampleInterfaceImplementation>();
    }

    [Test]
    public void TestStandardResolving()
    { 
      // setup

      // business
      var result = kernel.Get<IExampleInterface>();

      // verify
      result.Should().NotBeNull();
      result.Should().BeOfType<ExampleInterfaceImplementation>();
    }

    [Test]
    public void TestPropertyResolving()
    {
      // setup
      var exampleClass = new ExampleClass();

      // business
      kernel.Inject(exampleClass);

      // verify
      exampleClass.ExampleProperty.Should().NotBeNull();
      exampleClass.ExampleProperty.Should().BeOfType<ExampleInterfaceImplementation>();
    }
  }