public void TwoValueObjectsWithSameValuesButDifferentTypesAreNotEqual() { MyValueObject object1 = new MyValueObject("string", 100); MySimilarValueObject object2 = new MySimilarValueObject("string", 100); MyInheritedValueObject object3 = new MyInheritedValueObject("string", 100); MyExtendedValueObject object4 = new MyExtendedValueObject("string", 100, 102); Assert.AreNotSame(object1, object2); Assert.AreNotSame(object1, object3); Assert.AreNotSame(object1, object4); Assert.AreEqual(object1, object1); Assert.AreNotEqual(object1, object2); Assert.AreNotEqual(object2, object1); Assert.AreNotEqual(object1, object3); Assert.AreNotEqual(object3, object1); Assert.AreNotEqual(object1, object4); Assert.AreNotEqual(object4, object1); Assert.AreNotEqual(object1.GetHashCode(), object2.GetHashCode()); Assert.AreNotEqual(object2.GetHashCode(), object1.GetHashCode()); Assert.AreNotEqual(object1.GetHashCode(), object3.GetHashCode()); Assert.AreNotEqual(object3.GetHashCode(), object1.GetHashCode()); Assert.AreNotEqual(object1.GetHashCode(), object4.GetHashCode()); Assert.AreNotEqual(object4.GetHashCode(), object1.GetHashCode()); }
public void ToStringTest() { MyValueObject object1 = new MyValueObject("string", 100); MySimilarValueObject object2 = new MySimilarValueObject("string", 100); MyInheritedValueObject object3 = new MyInheritedValueObject("string", 100); MyExtendedValueObject object4 = new MyExtendedValueObject("string", 100, 102); MyOtherValueObject object5 = new MyOtherValueObject(); Assert.AreEqual(object1.ToString(), "Mikadocs.OEE.Test.ValueObjectTest+MyValueObject with values: (i: (100), s: (string))"); Assert.AreEqual(object2.ToString(), "Mikadocs.OEE.Test.ValueObjectTest+MySimilarValueObject with values: (i: (100), s: (string))"); Assert.AreEqual(object3.ToString(), "Mikadocs.OEE.Test.ValueObjectTest+MyInheritedValueObject with values: (i: (100), s: (string))"); Assert.AreEqual(object4.ToString(), "Mikadocs.OEE.Test.ValueObjectTest+MyExtendedValueObject with values: (d: (102), i: (100), s: (string))"); Assert.AreEqual(object5.ToString(), "Mikadocs.OEE.Test.ValueObjectTest+MyOtherValueObject with values: (none)"); }