Exemplo n.º 1
0
        public void Custom_equality_operator_is_not_called_through_reference_with_base_type()
        {
            object a = new CustomEqualsOperatorObject(1);
            object b = new CustomEqualsOperatorObject(1);

            Assert.IsFalse(a == b);
        }
Exemplo n.º 2
0
        public void Equality_operator_can_be_overridden()
        {
            var a = new CustomEqualsOperatorObject(1);
            var b = new CustomEqualsOperatorObject(1);
            var c = new CustomEqualsOperatorObject(2);

            Assert.IsTrue(a == a);
            Assert.IsTrue(a == b);
            Assert.IsTrue(a != c);
            Assert.IsFalse(a == c);
            Assert.IsFalse(a != b);
        }
Exemplo n.º 3
0
        public void ReferenceEqual_works_as_expected_even_though_both_Equal_and_equals_operator_are_overridden()
        {
            var a = new CustomEqualsOperatorObject(1);
            var b = new CustomEqualsOperatorObject(1);

            Assert.IsFalse(ReferenceEquals(a, b));
        }