public void KT_AreEqual() { var k1 = new KTExample { MappedString = "cow", MappedNested = new KTNested { MappedInt = 3, MappedRecursive = new KTNested { MappedInt = 99 }, Foos = { new Foo { Val = 42 } } } }; var k2 = new KTExample { MappedString = "cow", MappedNested = new KTNested { MappedInt = 3, MappedRecursive = new KTNested { MappedInt = 99 }, Foos = { new Foo { Val = 42 } } } }; Assert.IsTrue(k1.Equals(k2)); Assert.IsTrue(EqualityComparer <KTExample> .Default.Equals(k1, k2)); Assert.IsTrue(k1.Equals((object)k2)); Assert.IsTrue(k2.Equals(k1)); Assert.IsTrue(k2.Equals((object)k1)); Assert.IsTrue(object.Equals(k1, k2)); Assert.AreEqual(k1, k2); }
public void KT_AreNotEqual() { var k1 = new KTExample { MappedString = "cow", MappedNested = new KTNested { MappedInt = 3 } }; var k2 = new KTExample { MappedString = "cow", MappedNested = new KTNested { MappedInt = 4 } }; Assert.IsFalse(k1.Equals(k2)); Assert.IsFalse(k1.Equals(null)); Assert.IsFalse(object.Equals(k1, null)); }
public void KT_NestedAreNotEqual() { var k1 = new KTExample { MappedNested = new KTNested { MappedRecursive = new KTNested { MappedInt = 1 } } }; var k2 = new KTExample { MappedNested = new KTNested { MappedRecursive = new KTNested { MappedInt = 5 } } }; Assert.IsFalse(k1.Equals(k2)); }