Beispiel #1
0
        public void Equals_False_WithNoTypeComparer()
        {
            // Arrange
            var componentUnderTest = new FieldValueEqualityComparer();

            FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly });

            var lhs = new SimplePoco();
            var rhs = new InheritedSimplePoco();

            // Act
            var actual = componentUnderTest.Equals(lhs, rhs);

            // Assert
            Assert.AreEqual(false, actual);
        }
Beispiel #2
0
        public void Equals_True_WithEqualityComparer_AtTopLevel()
        {
            // Arrange
            var componentUnderTest = new FieldValueEqualityComparer();

            FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly });

            var lhs = new SimplePoco
            {
                MyString = "1"
            };
            var rhs = new InheritedSimplePoco
            {
                MyString = "xxx"
            };

            // Act
            FieldValueEqualityComparer.AddFieldValueEqualityComparer(new SimplePocoEqualityComparer());
            var actual = componentUnderTest.Equals(lhs, rhs);

            // Assert
            Assert.AreEqual(true, actual);
        }