예제 #1
0
 private void AssertNotEqual(TestValue value1, TestValue value2)
 {
     Assert.AreNotEqual(value1, value2);
     Assert.IsTrue(value1 != value2);
     Assert.IsFalse(value1 == value2);
     Assert.IsFalse(value1.Equals(value2));
 }
예제 #2
0
        public void Equals_NullIsConsideredEqual()
        {
            var value1 = new TestValue();
            var value2 = new TestValue();

            AssertEqual(value1, value2);
        }
예제 #3
0
        public void Equals_IgnoresPrivatePropertiesAndFields()
        {
            var value1 = new TestValue(5);
            var value2 = new TestValue(8);

            AssertEqual(value1, value2);
        }
예제 #4
0
        public void Equals_ComparingWithWrongType_ReturnsFalse()
        {
            var value = new TestValue {
                Property1 = "string"
            };

            Assert.IsFalse(value.Equals(10));
        }
예제 #5
0
        public void Equals_ComparingWithNull_ReturnsFalse()
        {
            var value = new TestValue {
                Property1 = "string"
            };

            Assert.IsFalse(value.Equals(null as object));
        }
예제 #6
0
        public void Equals_OnlyOneValueIsNull_DoesNotThrow_NotEqual()
        {
            var value1 = new TestValue();
            var value2 = new TestValue {
                Property1 = "value"
            };

            AssertNotEqual(value1, value2);
        }
예제 #7
0
        public void Equals_ComparesAllPropertiesAndFields_FieldDifferent_NotEqual()
        {
            var value1 = new TestValue {
                Property1 = "test", Property2 = 10, Field = 8
            };
            var value2 = new TestValue {
                Property1 = "test", Property2 = 10, Field = 9
            };

            AssertNotEqual(value1, value2);
        }
예제 #8
0
        public void GetHashCode_AlwaysEqualForEqualObjects()
        {
            var value1 = new TestValue {
                Property1 = "string", Property2 = 4
            };
            var value2 = new TestValue {
                Property1 = "string", Property2 = 4
            };

            Assert.AreEqual(value1.GetHashCode(), value2.GetHashCode());
        }
예제 #9
0
        public void GetHashCode_ConsidersPublicFields()
        {
            var value1 = new TestValue {
                Property2 = 2
            };
            var value2 = new TestValue {
                Property2 = 2, Field = 4
            };

            Assert.AreNotEqual(value1.GetHashCode(), value2.GetHashCode());
        }
예제 #10
0
        public void Equals_ComparesAllPropertiesAndFields_Equal()
        {
            var value1 = new TestValue {
                Property1 = "test", Property2 = 10, Field = 3
            };
            var value2 = new TestValue {
                Property1 = "test", Property2 = 10, Field = 3
            };

            AssertEqual(value1, value2);
        }
예제 #11
0
        public void GetHashCode_HandlesNull()
        {
            var value1 = new TestValue {
                Property2 = 2
            };
            var value2 = new TestValue {
                Property2 = 5
            };

            Assert.AreNotEqual(value1.GetHashCode(), value2.GetHashCode());
        }
예제 #12
0
        public void GetHashCode_NotEqualForDistinctObjects_2()
        {
            var value1 = new TestValue {
                Property1 = "string", Property2 = 4
            };
            var value2 = new TestValue {
                Property1 = "String", Property2 = 4
            };

            Assert.AreNotEqual(value1.GetHashCode(), value2.GetHashCode());
        }
예제 #13
0
        public void OperatorEquals_LeftSideNull_ReturnsFalse()
        {
            var value = new TestValue();

            Assert.IsFalse(null == value);
        }
예제 #14
0
        public void OperatorEquals_RightSideNull_ReturnsFalse()
        {
            var value = new TestValue();

            Assert.IsFalse(value == null);
        }
예제 #15
0
        public void OperatorNotEquals_LeftSideNull_ReturnsTrue()
        {
            var value = new TestValue();

            Assert.IsTrue(null != value);
        }
예제 #16
0
        public void OperatorNotEquals_RightSideNull_ReturnsTrue()
        {
            var value = new TestValue();

            Assert.IsTrue(value != null);
        }
예제 #17
0
        public void ImplementsIEquatable()
        {
            var value = new TestValue();

            Assert.IsInstanceOfType(value, typeof(IEquatable <ValueObject>));
        }