Esempio n. 1
0
        public void IgnoreTranspositionByDeletion()
        {
            var originalDocument = @"
                - dolor: sit
            ";
            var changedDocument  = @"
                - amet: elit
                - dolor: sit
            ";

            var result = new SequenceNodeComparer().Compare(new Path(), (YamlSequenceNode)Parser.Parse(originalDocument), (YamlSequenceNode)Parser.Parse(changedDocument));

            Assert.Equal(2, result.Count());
            Assert.Equal(new object[] { 0 }, result.ElementAt(0).Path.Segments);
            Assert.Equal(ChangeType.Deletion, result.ElementAt(0).ChangeType);
            Assert.Equal(new object[] { 0 }, result.ElementAt(1).Path.Segments);
            Assert.Equal(ChangeType.ImplicitTransposition, result.ElementAt(1).ChangeType);
        }
Esempio n. 2
0
        public void DetectTransposedChild()
        {
            var originalDocument = @"
                - lorem: ipsum
                - dolor: sit
                - amet: elit
            ";
            var changedDocument  = @"
                - dolor: sit
                - amet: elit
                - lorem: ipsum
            ";

            var result = new SequenceNodeComparer().Compare(new Path(), (YamlSequenceNode)Parser.Parse(originalDocument), (YamlSequenceNode)Parser.Parse(changedDocument));

            Assert.Equal(3, result.Count());
            Assert.Equal(new object[] { 0 }, result.ElementAt(0).Path.Segments);
            Assert.Equal(ChangeType.Transposition, result.ElementAt(0).ChangeType);
            Assert.Equal(new object[] { 1 }, result.ElementAt(1).Path.Segments);
            Assert.Equal(ChangeType.ImplicitTransposition, result.ElementAt(1).ChangeType);
            Assert.Equal(new object[] { 2 }, result.ElementAt(2).Path.Segments);
            Assert.Equal(ChangeType.ImplicitTransposition, result.ElementAt(2).ChangeType);
        }