Ejemplo n.º 1
0
        public void ShouldDiff_JToken()
        {
            var obj1 = JToken.Parse(@"{ ""list"": [""test1"", ""test2""] }");
            var obj2 = JToken.Parse(@"{ ""list"": [""test3"", ""test4""] }");
            var diff = AnyDiff.Diff(obj1, obj2);

            Assert.AreEqual(4, diff.Count);
        }
Ejemplo n.º 2
0
        public void ShouldDetect_Differences_TestFixtureData()
        {
            var obj1 = new TestFixtureData(new { Field1 = "Test" });
            var obj2 = new TestFixtureData(new { Field1 = "Test 2" });

            var diff = AnyDiff.Diff(obj1, obj2);

            Assert.AreEqual(1, diff.Count);
        }
Ejemplo n.º 3
0
        public void ShouldDetect_Differences_Point()
        {
            var obj1 = new Point(100, 200);
            var obj2 = new Point(101, 200);

            var diff = AnyDiff.Diff(obj1, obj2, ComparisonOptions.CompareProperties);

            Assert.AreEqual(1, diff.Count);
        }
Ejemplo n.º 4
0
        public void ShouldDetect_Differences_CircularReferences()
        {
            var obj1 = new CircularReferenceObject(100);
            var obj2 = new CircularReferenceObject(200);

            obj1.Parent = obj1;
            obj2.Parent = obj2;

            var diff = AnyDiff.Diff(obj1, obj2);

            Assert.AreEqual(1, diff.Count);
        }
Ejemplo n.º 5
0
        public void ShouldDiff_BuildDefinition()
        {
            var obj1 = new BuildDefinition()
            {
                AuthoredBy = new Microsoft.VisualStudio.Services.WebApi.IdentityRef {
                    UniqueName = "Test Name", DisplayName = "Display Name"
                },
                BadgeEnabled = true,
                Comment      = "Test Comment",
                Id           = 1,
            };

            obj1.SetPropertyValue("LatestBuild", new Build {
                Id = 1
            });
            obj1.LatestBuild.Properties.Add("test property", "property value");
            obj1.Drafts.Add(new DefinitionReference {
                Name = "Definition 1"
            });
            obj1.Metrics.Add(new BuildMetric {
                Name = "Metric 1"
            });
            obj1.Variables.Add("test", new BuildDefinitionVariable {
                Value = "Test value"
            });
            var obj2 = new BuildDefinition()
            {
                AuthoredBy = new Microsoft.VisualStudio.Services.WebApi.IdentityRef {
                    UniqueName = "Test Name", DisplayName = "Display Name 2"
                },
                BadgeEnabled = true,
                Comment      = "Test Comment 2",
                Id           = 1
            };

            obj2.SetPropertyValue("LatestBuild", new Build {
                Id = 2
            });
            obj2.LatestBuild.Properties.Add("test property", "property value");
            obj2.Drafts.Add(new DefinitionReference {
                Name = "Definition 1"
            });
            obj2.Metrics.Add(new BuildMetric {
                Name = "Metric 1"
            });
            obj2.Variables.Add("test", new BuildDefinitionVariable {
                Value = "Test value"
            });
            var diff = AnyDiff.Diff(obj1, obj2);

            Assert.AreEqual(3, diff.Count);
        }
Ejemplo n.º 6
0
        public void ShouldDetect_NoDifferences_ComplexObject()
        {
            var date = new DateTime(2018, 12, 1, 5, 1, 30);
            var obj1 = new ComplexObject(100, 200, date, "Test user");
            var obj2 = new ComplexObject(100, 200, date, "Test user");

            obj1.TestEnum = TestEnum.Value1;
            obj1.AddInt(5000);
            obj1.AddInt(6000);
            obj1.AddInt(7000);

            obj2.TestEnum = TestEnum.Value1;
            obj2.AddInt(5000);
            obj2.AddInt(6000);
            obj2.AddInt(7000);

            var diff = AnyDiff.Diff(obj1, obj2);

            Assert.AreEqual(0, diff.Count);
        }