public void HashCodeAndEqualTest() { Oid oid = new Oid(Meta.GetAssetType("Story"), 5, null); Oid oid2 = Oid.FromToken("Story:5", Meta); Assert.AreEqual(oid, oid2); Assert.AreEqual(oid.GetHashCode(), oid2.GetHashCode()); }
public void FromTokenIsNull() { Oid oid = Oid.FromToken("NULL", Meta); Assert.AreEqual(Oid.Null, oid); Assert.AreSame(Oid.Null, oid); Assert.AreEqual(Oid.Null.GetHashCode(), oid.GetHashCode()); }
public void HashCodeAndEqualWithMomentTest() { Oid oid = new Oid(Meta.GetAssetType("Story"), 5, 555); Oid oid2 = Oid.FromToken("Story:5:555", Meta); Oid anotherOid = Oid.FromToken("Story:5:666", Meta); Oid momentlessOid = Oid.FromToken("Story:5", Meta); Assert.AreEqual(oid, oid2); Assert.AreEqual(oid.GetHashCode(), oid2.GetHashCode()); Assert.AreNotEqual(oid, anotherOid); Assert.AreNotEqual(oid, momentlessOid); Assert.AreNotEqual(momentlessOid, anotherOid); }
public override int GetHashCode() { // The value of GetHashCode should not be allowed to change during an objects lifetime! // If it does, it leads to crazy problems with Dictionaries etc (as they cache the value) // ReSharper disable NonReadonlyFieldInGetHashCode // ReSharper disable BaseObjectGetHashCodeCallInGetHashCode if (_requestedHashCode.HasValue) { return(_requestedHashCode.Value); } var hashCode = HasOidAssigned ? Oid.GetHashCode() : base.GetHashCode(); _requestedHashCode = hashCode; return(hashCode); // ReSharper restore BaseObjectGetHashCodeCallInGetHashCode // ReSharper restore NonReadonlyFieldInGetHashCode }
public override int GetHashCode() { return(Oid.GetHashCode()); }
public override int GetHashCode() { return(oid != null ? oid.GetHashCode() : 0); }
public void HashCodeAndEqualWithMomentTest() { Oid oid = new Oid(Meta.GetAssetType("Story"), 5, 555); Oid oid2 = Oid.FromToken("Story:5:555", Meta); Oid anotherOid = Oid.FromToken("Story:5:666", Meta); Oid momentlessOid = Oid.FromToken("Story:5", Meta); Assert.AreEqual(oid, oid2); Assert.AreEqual(oid.GetHashCode(), oid2.GetHashCode()); Assert.AreNotEqual(oid, anotherOid); Assert.AreNotEqual(oid, momentlessOid); Assert.AreNotEqual(momentlessOid, anotherOid); }
public void HashCodeAndEqualTest() { Oid oid = new Oid(Meta.GetAssetType("Story"), 5, null); Oid oid2 = Oid.FromToken("Story:5", Meta); Assert.AreEqual(oid, oid2); Assert.AreEqual(oid.GetHashCode(), oid2.GetHashCode()); }