コード例 #1
0
        public void ObjectWithListMatches()
        {
            var a =
                new ObjectWithList
            {
                Number  = 2,
                String  = "string",
                Decimal = 20.000000000000000000001,
                List    = new List <int> {
                    1, 2, 3, 4, 5, 6, 7, 8, 9
                }
            };

            var b =
                new ObjectWithList
            {
                Number  = 2,
                String  = "string",
                Decimal = 20.000000000000000000001,
                List    = new List <int> {
                    1, 2, 3, 4, 5, 6, 7, 8, 9
                }
            };


            var result = _calculator.Diff(a, b);

            Assert.True(result.ValuesMatch);
        }
コード例 #2
0
        public void ListIsTheSame()
        {
            var a = new List <string> {
                "hi", "there"
            };
            var b = new List <string> {
                "hi", "there"
            };

            var result = _calculator.Diff(a, b);

            Assert.True(result.ValuesMatch);
        }
コード例 #3
0
        public void NothingIsIgnoredWhenNothingIsSpecified()
        {
            var calculator = new DiffCalculator();
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 3.1, 4.1 };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
コード例 #4
0
        public void AClassIsIgnored()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] {typeof (double)});
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 3.1, 4.1 };

            var result = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;
            Assert.True(resultMatch);
        }
コード例 #5
0
        public void AClassIsNotIgnoredWhenItIsntDiffed()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] { typeof(decimal) });
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 3.1, 4.1 };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
コード例 #6
0
ファイル: IgnoredFieldsTest.cs プロジェクト: etkirsch/NetDiff
        public void IgnoresFieldsContainingByType()
        {
            var calculator = new DiffCalculator(ignoreFieldsContainingByType: new Dictionary<Type, string[]> { { typeof(SlightlyDifferentObject), new[] { "String" } } });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
コード例 #7
0
        public void IgnoresFieldsContaining()
        {
            var calculator = new DiffCalculator(
                ignoreFieldsContaining: new[] { "String" });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
コード例 #8
0
ファイル: IgnoredFieldsTest.cs プロジェクト: etkirsch/NetDiff
        public void IgnoresFieldsContaining()
        {
            var calculator = new DiffCalculator(
    ignoreFieldsContaining: new[] { "String" });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
コード例 #9
0
ファイル: IgnoreMatchesTest.cs プロジェクト: etkirsch/NetDiff
        public void ItemsFieldIsEmptySet()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 1.1, 2.1, 3.1 };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            Assert.False(items.Any());
        }
コード例 #10
0
ファイル: IgnoreMatchesTest.cs プロジェクト: etkirsch/NetDiff
        public void AllMatchesAreIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 5.1, 2.1, 4.1 };

            var result = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;
            var items = ((ObjectDiff)result).Items;

            Assert.False(resultMatch);
            Assert.Equal(2, items.Count());
        }
コード例 #11
0
        public void IgnoresFieldsContainingByType()
        {
            var calculator = new DiffCalculator(ignoreFieldsContainingByType: new Dictionary <Type, string[]> {
                { typeof(SlightlyDifferentObject), new[] { "String" } }
            });

            var a = new SlightlyDifferentObject(secondString: "hi");
            var b = new SlightlyDifferentObject(secondString: "there");

            var resultObject = calculator.Diff(a, b);

            Assert.True(resultObject.ValuesMatch);
        }
コード例 #12
0
ファイル: IgnoreMatchesTest.cs プロジェクト: etkirsch/NetDiff
        public void MatchesAreNotIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: false);
            var a = new List<double> { 1.1, 2.1, 3.1 };
            var b = new List<double> { 1.1, 2.1, 3.1 };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            // Currently <= because there are some hidden fields included
            Assert.True(3 <= items.Count());
        }
コード例 #13
0
        public void AClassIsNotIgnoredWhenItIsntDiffed()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] { typeof(decimal) });
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 3.1, 4.1
            };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
コード例 #14
0
        public void NothingIsIgnoredWhenNothingIsSpecified()
        {
            var calculator = new DiffCalculator();
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 3.1, 4.1
            };

            var result = calculator.Diff(a, b);

            Assert.False(result.ValuesMatch);
        }
コード例 #15
0
        public void AClassIsIgnored()
        {
            var calculator = new DiffCalculator(ignoredClasses: new[] { typeof(double) });
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 3.1, 4.1
            };

            var result      = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;

            Assert.True(resultMatch);
        }
コード例 #16
0
        public void ItemsFieldIsEmptySet()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                1.1, 2.1, 3.1
            };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            Assert.False(items.Any());
        }
コード例 #17
0
        public void AllMatchesAreIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: true);
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                5.1, 2.1, 4.1
            };

            var result      = calculator.Diff(a, b);
            var resultMatch = result.ValuesMatch;
            var items       = ((ObjectDiff)result).Items;

            Assert.False(resultMatch);
            Assert.Equal(2, items.Count());
        }
コード例 #18
0
        public void MatchesAreNotIgnored()
        {
            var calculator = new DiffCalculator(ignoreMatches: false);
            var a          = new List <double> {
                1.1, 2.1, 3.1
            };
            var b = new List <double> {
                1.1, 2.1, 3.1
            };

            var result = calculator.Diff(a, b);

            var items = ((ObjectDiff)result).Items;

            Assert.True(result.ValuesMatch);
            // Currently <= because there are some hidden fields included
            Assert.True(3 <= items.Count());
        }
コード例 #19
0
ファイル: ObjectExtensions.cs プロジェクト: etkirsch/NetDiff
 public static BaseDiff DiffAgainst(this object baseObject, object antagonist)
 {
     var calculator = new DiffCalculator();
     return calculator.Diff(baseObject, antagonist);
 }
コード例 #20
0
        public static BaseDiff DiffAgainst(this object baseObject, object antagonist)
        {
            var calculator = new DiffCalculator();

            return(calculator.Diff(baseObject, antagonist));
        }