public void DifferentValuesAreUnequal() { var a = new SampleValueObject { ShortValue = 2000, StringValue = "A", Value = -1 }; // ReSharper disable once SuspiciousTypeConversion.Global PAssert.That(() => !a.Equals("test")); }
public void CanCompareWithNull() { var a = new SampleValueObject { ShortValue = 2000, StringValue = "A", Value = -1 }; SampleValueObject b = null; PAssert.That(() => b == null && null == b && a != b ); }
public void IdenticalValuesAreEqual() { var a = new SampleValueObject { ShortValue = 2000, StringValue = "A", Value = -1 }; var b = new SampleValueObject { ShortValue = 2000, StringValue = "A", Value = -1 }; PAssert.That(() => a.Equals(b) && a == b && a.GetHashCode() == b.GetHashCode() && !ReferenceEquals(a, b) ); }
public void DifferentValuesAreUnequal() { var a = new SampleValueObject { ShortValue = 2000, StringValue = "A", Value = -1 }; var b = new SampleValueObject { ShortValue = 2000, StringValue = "a", Value = -1 }; PAssert.That(() => !a.Equals(b) && a != b && a.GetHashCode() != b.GetHashCode() && !ReferenceEquals(a, b) ); }
public void NullIsNotEqual() { var a = new SampleValueObject { ShortValue = 2000, StringValue = "A", Value = -1 }; var typedNull = default(SampleValueObject); var untypedNull = default(object); // ReSharper disable once NegativeEqualityExpression PAssert.That(() => !a.Equals(typedNull) && !a.Equals(untypedNull) && a != typedNull && !(a == typedNull) && typedNull != a // ReSharper disable once EqualExpressionComparison && !(a != a) ); }