0

テストが実行されると、うまく機能する次のコードがあります。

しかし、その後、これらのテスト + コード カバレッジ計算 (SharpDevelop 4) を実行しようとすると、例外がスローされます。

誰かがなぜこれが起こるのか説明できますか?

SetUp : System.Security.VerificationException : 操作により、ランタイムが不安定になる可能性があります。

  [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>();
    }
  }
4

1 に答える 1

2

SharpDevelopPartCoverを使用してコード カバレッジを行います。これは、 AllowPartiallyTrustedCallersAttributeなどを使用するアセンブリで実行する場合の既知の問題(末尾を参照) に関連しているようです。

修正は最新のメンテナンス リリースに含まれているはずですが、SharpDevelop が最新のリリースをパッケージ化したかどうかはわかりません。

于 2012-03-12T21:35:38.923 に答える