I'm getting an internal NullReferenceException
from NUnit 2.6.4 while running a unit test fixture:
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
I've tried with both JetBeans Rider and MonoDevelop. I believe it has something to do with my implementation of IEquatable because the issue goes away when I remove the implementation.
My implementation involves a class deriving an abstract class that implements IEquatable<Derived>
, with the following functions defined/overwritten (as well as == and != operators):
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();
}
Is this an NUnit bug or is there something wrong with my implementation?