public void PrimitiveDataObject_HashCode_Pass_Ids() { // Arrange Data Guid parentId = Guid.NewGuid(); var x = new PrimitiveDataObject() { Id = 1, ParentId = parentId, StringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IgnoreStringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IntValue = 2, IgnoreIntValue = 2, BoolValue = true, IgnoreBoolValue = true, DoubleValue = 0.123456789, IgnoreDoubleValue = 0.123456789, }; var y = new PrimitiveDataObject() { Id = 1, ParentId = parentId, StringValue = "abcdefghijklmnopqrstuvwxyz", IgnoreStringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IntValue = 5, IgnoreIntValue = 2, BoolValue = false, IgnoreBoolValue = true, DoubleValue = 0.987654321, IgnoreDoubleValue = 0.123456789, }; // Act var xHashCode = this.PrimitiveEqualityComparer.GetHashCode(x); var yHashCode = this.PrimitiveEqualityComparer.GetHashCode(y); // Assert Assert.AreEqual(xHashCode, yHashCode); Assert.AreEqual(x.GetHashCode(), y.GetHashCode()); }
public void PrimitiveDataObject_HashCode_Fail_ParentId() { // Arrange Data Guid parentId = Guid.NewGuid(); var x = new PrimitiveDataObject() { Id = 1, ParentId = Guid.NewGuid(), StringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IgnoreStringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IntValue = 2, IgnoreIntValue = 2, BoolValue = true, IgnoreBoolValue = true, DoubleValue = 0.123456789, IgnoreDoubleValue = 0.123456789, }; var y = new PrimitiveDataObject() { Id = 1, ParentId = Guid.NewGuid(), StringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IgnoreStringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IntValue = 2, IgnoreIntValue = 2, BoolValue = true, IgnoreBoolValue = true, DoubleValue = 0.123456789, IgnoreDoubleValue = 0.123456789, }; // Act var xHashCode = this.PrimitiveEqualityComparer.GetHashCode(x); var yHashCode = this.PrimitiveEqualityComparer.GetHashCode(y); // Assert Assert.AreNotEqual(xHashCode, yHashCode); Assert.AreNotEqual(x.GetHashCode(), y.GetHashCode()); }
public void PrimitiveDataObject_Equal_Fail_ParentId() { // Arrange Data Guid parentId = Guid.NewGuid(); var x = new PrimitiveDataObject() { Id = 1, ParentId = Guid.NewGuid(), StringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IgnoreStringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IntValue = 2, IgnoreIntValue = 2, BoolValue = true, IgnoreBoolValue = true, DoubleValue = 0.123456789, IgnoreDoubleValue = 0.123456789, }; var y = new PrimitiveDataObject() { Id = 1, ParentId = Guid.NewGuid(), StringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IgnoreStringValue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", IntValue = 2, IgnoreIntValue = 2, BoolValue = true, IgnoreBoolValue = true, DoubleValue = 0.123456789, IgnoreDoubleValue = 0.123456789, }; // Act var areEqual = this.PrimitiveEqualityComparer.Equals(x, y); // Assert Assert.IsFalse(areEqual); Assert.IsFalse(x.Equals(y)); }