C# NUnit GetResultState引发NullReferenceException

C# NUnit GetResultState引发NullReferenceException,c#,nunit,iequatable,C#,Nunit,Iequatable,在运行单元测试夹具时,我从NUnit 2.6.4获得一个内部NullReferenceException: SetUp : System.NullReferenceException : Object reference not set to an instance of an object at NUnit.Core.NUnitFramework.GetResultState (System.Exception ex) <0x40e3da10 + 0x00068> in <

在运行单元测试夹具时,我从NUnit 2.6.4获得一个内部
NullReferenceException

SetUp : System.NullReferenceException : Object reference not set to an instance of an object
  at NUnit.Core.NUnitFramework.GetResultState (System.Exception ex) <0x40e3da10 + 0x00068> in <filename unknown>:0 
  at NUnit.Core.TestMethod.RecordException (System.Exception exception, NUnit.Core.TestResult testResult, FailureSite failureSite) <0x40e3d920 + 0x00093> in <filename unknown>:0 
  at NUnit.Core.TestMethod.RunTestCase (NUnit.Core.TestResult testResult) <0x40e34a30 + 0x00168> in <filename unknown>:0 
  at NUnit.Core.TestMethod.RunTest () <0x40e30060 + 0x0013f> in <filename unknown>:0

这是NUnit错误还是我的实现有问题?

如何定义==和!=运算符?==只比较对象中的几个公共字段,并且!=定义为==的倒数可能是一个bug,因为NUnit v2未维护。以下是NUnit3.x中的一些最新修复,也可能出现在v2中:这是我的第一个想法。我想尝试在3.6.1上运行它,但每次运行时都会出现
不受支持的框架异常
    public override bool Equals(object o){
        var a = o as Derived;
        return a != null && Equals(a);
    }

    public new static bool Equals(object a, object b){
        if(a == null || b == null) return false;
        if(a.GetType() != typeof(Derived) || b.GetType() != typeof(Derived))
            return false;
        return ((Derived) a).Equals((Derived) b);
    }

    public bool Equals(Derived a){
        return a != null && a.Id == Id;
    }

    public override int GetHashCode(){
        // ReSharper disable once NonReadonlyMemberInGetHashCode
        return _id.GetHashCode();
    }