예제 #1
0
        public void TwoTypes_GetDifferences_ReturnsDifferences()
        {
            var firstToCompare = new FirstToCompare {
                AProperty = "Test", BProperty = 1
            };
            var secondToCompare = new SecondToCompare {
                AProperty = "Test", BProperty = 5000
            };

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

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

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