public void RealmObject_GetHashCode_IsDifferentForDifferentObjects() { var objA = new RequiredPrimaryKeyStringObject { StringProperty = "a" }; var objB = new RequiredPrimaryKeyStringObject { StringProperty = "b" }; Assert.That(objB.GetHashCode(), Is.Not.EqualTo(objA.GetHashCode()), "Different unmanaged objects should have different hash codes"); _realm.Write(() => { _realm.Add(objA); _realm.Add(objB); }); Assert.That(objA.GetHashCode(), Is.Not.EqualTo(objB.GetHashCode()), "Different managed objects should have different hashes"); }
public void RealmObject_GetHashCode_ChangesAfterAddingToRealm() { var objA = new RequiredPrimaryKeyStringObject { StringProperty = "a" }; var unmanagedHash = objA.GetHashCode(); Assert.That(objA.GetHashCode(), Is.EqualTo(unmanagedHash), "The hash code of an unmanaged object should be stable"); _realm.Write(() => { _realm.Add(objA); }); var managedHash = objA.GetHashCode(); Assert.That(unmanagedHash, Is.Not.EqualTo(managedHash), "The hash code should change after the object is managed"); Assert.That(objA.GetHashCode(), Is.EqualTo(managedHash), "The hash code of a managed object should be stable"); }