示例#1
0
        public void OneType_GetDifferences_ReturnsDifferences()
        {
            var firstToCompare = new FirstToCompare {
                AProperty = "Test", BProperty = 1
            };
            var secondToCompare = new FirstToCompare {
                AProperty = "Test", BProperty = 5000
            };

            var comparisons = new List <PropertyComparison <FirstToCompare> >
            {
                new PropertyComparison <FirstToCompare>(
                    nameof(firstToCompare.AProperty)),
                new PropertyComparison <FirstToCompare>(
                    nameof(firstToCompare.BProperty))
            };

            var differences = new ObjectComparer <FirstToCompare>(comparisons)
                              .GetDifferences(firstToCompare, secondToCompare);

            var propertyComparisons = differences.ToList();

            Assert.AreEqual(1, propertyComparisons.Count);
            Assert.AreEqual(propertyComparisons.First().FirstPropertyName, nameof(FirstToCompare.BProperty));
        }