示例#1
0
        public void DifferentValuesAreUnequal()
        {
            var a = new SampleValueObject {
                ShortValue = 2000, StringValue = "A", Value = -1
            };

            // ReSharper disable once SuspiciousTypeConversion.Global
            PAssert.That(() => !a.Equals("test"));
        }
示例#2
0
        public void CanCompareWithNull()
        {
            var a = new SampleValueObject {
                ShortValue = 2000, StringValue = "A", Value = -1
            };
            SampleValueObject b = null;

            PAssert.That(() =>
                         b == null && null == b && a != b
                         );
        }
示例#3
0
        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)
                         );
        }
示例#4
0
        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)
                         );
        }
示例#5
0
        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)
                         );
        }