示例#1
0
        public void AreEqual_True_ComplexPoco()
        {
            // Arrange
            var componentUnderTest = new FieldValueEqualityComparer();

            FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly });
            var simplePoco = new SimplePoco {
                MyInt = 23
            };
            var lhs = new ComplexPoco
            {
                MyInt                = 1,
                MyStrings            = new[] { "1", "2" },
                SimplePocoArray      = new[] { new SimplePoco(), simplePoco },
                SimplePocoDictionary = new Dictionary <string, SimplePoco>
                {
                    { "1", new SimplePoco {
                          MyString = "test"
                      } },
                    { "2", simplePoco }
                },
                Bytes = Encoding.Default.GetBytes("test")
            };
            var rhs = new ComplexPoco
            {
                MyInt                = 1,
                MyStrings            = new[] { "1", "2" },
                SimplePocoArray      = new[] { new SimplePoco(), simplePoco },
                SimplePocoDictionary = new Dictionary <string, SimplePoco>
                {
                    { "1", new SimplePoco {
                          MyString = "test"
                      } },
                    { "2", simplePoco }
                },
                Bytes = Encoding.Default.GetBytes("test")
            };

            // Act
            var actual = FieldValueEqualityComparer.AreEqual(lhs, rhs);

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