Exemple #1
0
        public void TestMergeAddAndRemove()
        {
            ICollection <MergeTestData> toRemove = new List <MergeTestData>();
            ICollection <MergeTestData> toAdd    = new List <MergeTestData>();

            Merge.ThreeWay(
                reference: MergeTestData.BuildList("a", "b", "c"),
                theirs: MergeTestData.BuildList("a", "b", "d"),
                mine: MergeTestData.BuildList("a", "c", "e"),
                added: toAdd, removed: toRemove);

            toAdd.Should().Equal(MergeTestData.BuildList("d"));
            toRemove.Should().Equal(MergeTestData.BuildList("c"));
        }
Exemple #2
0
        public void TestMergeModify()
        {
            var reference = MergeTestData.BuildList("a", "b", "c", "d", "e");
            var theirs    = new[]
            {
                new MergeTestData {
                    MergeID = "a"
                },
                new MergeTestData {
                    MergeID = "b", Data = "123", Timestamp = new DateTime(2000, 1, 1)
                },
                new MergeTestData {
                    MergeID = "c"
                },
                new MergeTestData {
                    MergeID = "d", Data = "456", Timestamp = new DateTime(2000, 1, 1)
                },
                new MergeTestData {
                    MergeID = "e", Data = "789", Timestamp = new DateTime(2999, 1, 1)
                }
            };
            var mine = new[]
            {
                new MergeTestData {
                    MergeID = "a"
                },
                new MergeTestData {
                    MergeID = "b"
                },
                new MergeTestData {
                    MergeID = "c", Data = "abc", Timestamp = new DateTime(2000, 1, 1)
                },
                new MergeTestData {
                    MergeID = "d", Data = "def", Timestamp = new DateTime(2999, 1, 1)
                },
                new MergeTestData {
                    MergeID = "e", Data = "ghi", Timestamp = new DateTime(2000, 1, 1)
                }
            };

            ICollection <MergeTestData> toRemove = new List <MergeTestData>();
            ICollection <MergeTestData> toAdd    = new List <MergeTestData>();

            Merge.ThreeWay(reference, theirs, mine, toAdd, toRemove);

            toRemove.Should().Equal(mine[1], mine[4]);
            toAdd.Should().Equal(theirs[1], theirs[4]);
        }