Exemplo n.º 1
0
        public void GetPatchOperations11()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    "The metrics for clarity are more-well understood. Do you have a game PLAN to become peerlessly synergetic across all platforms ? Think interactive".Split(' '),
                    //0    1       2    3     4      5      6           7  8   9   10 11   12  13   14      15        16         17   18   19       20 21     22
                    //0    1       2    3         4     5         6         7  8   9   10 11  12   13  14         15     16  17   18
                    "The metrics for obfuscation are more-well understood. Do you have a game plan to become cross-media ? Think interactive".Split(' '));

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateCopy(0, 2),
                PatchOperation.CreateAddition(3, 3),
                PatchOperation.CreateDeletion(3, 3),
                PatchOperation.CreateCopy(4, 11),
                PatchOperation.CreateAddition(12, 12),
                PatchOperation.CreateDeletion(12, 12),
                PatchOperation.CreateCopy(13, 14),
                PatchOperation.CreateAddition(15, 15),
                PatchOperation.CreateDeletion(15, 19),
                PatchOperation.CreateCopy(20, 22)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
        public void CreateCopy()
        {
            PatchOperation patchOperation = PatchOperation.CreateCopy(new Range <int>(10, 15));

            Assert.AreEqual(PatchOperationType.Copy, patchOperation.Type);
            Assert.AreEqual(new Range <int>(10, 15), patchOperation.Copy);
        }
        public void Equals()
        {
            Assert.AreEqual(PatchOperation.CreateAddition(1, 10), PatchOperation.CreateAddition(1, 10));
            Assert.AreEqual(PatchOperation.CreateDeletion(1, 10), PatchOperation.CreateDeletion(1, 10));
            Assert.AreEqual(PatchOperation.CreateCopy(1, 10), PatchOperation.CreateCopy(1, 10));

            Assert.AreNotEqual(PatchOperation.CreateAddition(1, 10), PatchOperation.CreateDeletion(1, 10));
            Assert.AreNotEqual(PatchOperation.CreateAddition(1, 10), PatchOperation.CreateCopy(1, 10));
            Assert.AreNotEqual(PatchOperation.CreateAddition(1, 10), PatchOperation.CreateAddition(10, 1));

            Assert.AreNotEqual(PatchOperation.CreateDeletion(1, 10), PatchOperation.CreateAddition(1, 10));
            Assert.AreNotEqual(PatchOperation.CreateDeletion(1, 10), PatchOperation.CreateDeletion(10, 1));
            Assert.AreNotEqual(PatchOperation.CreateDeletion(1, 10), PatchOperation.CreateCopy(10, 1));

            Assert.AreNotEqual(PatchOperation.CreateCopy(1, 10), PatchOperation.CreateAddition(1, 10));
            Assert.AreNotEqual(PatchOperation.CreateCopy(1, 10), PatchOperation.CreateCopy(10, 1));
            Assert.AreNotEqual(PatchOperation.CreateCopy(1, 10), PatchOperation.CreateDeletion(10, 1));

            Assert.AreNotEqual(PatchOperation.CreateAddition(1, 1), null);
            Assert.AreNotEqual(PatchOperation.CreateAddition(1, 1), string.Empty);

            Assert.AreNotEqual(PatchOperation.CreateDeletion(1, 1), null);
            Assert.AreNotEqual(PatchOperation.CreateDeletion(1, 1), string.Empty);

            Assert.AreNotEqual(PatchOperation.CreateCopy(1, 1), null);
            Assert.AreNotEqual(PatchOperation.CreateCopy(1, 1), string.Empty);
        }
Exemplo n.º 4
0
        public void GetPatchOperations5()
        {
            DiffEngine <long> diffEngine = new DiffEngine <long>(
                new long[] { 1, 2, 3 }, new long[] { 2, 3 });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateDeletion(0, 0),
                PatchOperation.CreateCopy(1, 2)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
Exemplo n.º 5
0
        public void GetPatchOperations2()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    new string[] { "a", "b", "c", "d" },
                    new string[] { "c", "d" });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateDeletion(0, 1),
                PatchOperation.CreateCopy(2, 3)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
Exemplo n.º 6
0
        public void GetPatchOperations9()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    new string[] { "same", "same", "same", "", "same", "del", "", "del" },
                    new string[] { "ins", "", "same", "same", "same", "", "same" });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateAddition(0, 1),
                PatchOperation.CreateCopy(0, 4),
                PatchOperation.CreateDeletion(5, 7)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
Exemplo n.º 7
0
        public void GetPatchOperations4()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    new string[] { "a", "b", "c", "d", "e" },
                    new string[] { "a", "x", "y", "b", "c", "j", "e", });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateCopy(0, 0),
                PatchOperation.CreateAddition(1, 2),
                PatchOperation.CreateCopy(1, 2),
                PatchOperation.CreateAddition(5, 5),
                PatchOperation.CreateDeletion(3, 3),
                PatchOperation.CreateCopy(4, 4)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
Exemplo n.º 8
0
        public void GetPatchOperations7()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    new string[] {
                "a", "a", "a", "a", "b", "b", "b", "a", "a", "a", "a", "b", "b", "b", "a", "a",
                "a", "a", "b", "b", "b", "a", "a", "a", "a", "b", "b", "b"
            },
                    new string[] {
                "a", "a", "a", "a", "b", "b", "b", "a", "b", "b", "b", "a", "a", "a", "a"
            });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateCopy(0, 7),
                PatchOperation.CreateDeletion(8, 10),
                PatchOperation.CreateCopy(11, 17),
                PatchOperation.CreateDeletion(18, 27)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
Exemplo n.º 9
0
        public void GetPatchOperations6()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" },
                    new string[] {
                "a", "b", "p", "q", "r", "s", "t", "c", "d", "e", "f", "g", "h",
                "i", "j", "u", "l"
            });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateCopy(0, 1),
                PatchOperation.CreateAddition(2, 6),
                PatchOperation.CreateCopy(2, 9),
                PatchOperation.CreateAddition(15, 15),
                PatchOperation.CreateDeletion(10, 10),
                PatchOperation.CreateCopy(11, 11)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
Exemplo n.º 10
0
        public void GetPatchOperations8()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    new string[] {
                "A", "B", "C", "D", "E", "F", "G", "A", "H", "I", "J", "D", "K",
                "L", "C", "G", "M", "H", "N", "J", "I", "K", "O", "C", "G", "M",
                "P", "Q", "J", "R", "K", "S", "C", "C", "F", "G", "D", "TKey", "N",
                "G", "M", "U", "V", "J", "Q", "K", "W", "C", "G", "M", "X", "C",
                "V", "K", "Y", "C", "G", "G", "A", "Z", "AA", "J", "C", "Z", "G",
                "V", "K", "BB", "C", "G", "M", "CC", "DD", "J", "EE", "K", "FF",
                "C", "AA", "G", "M", "GG", "K", "HH", "C", "DD", "G", "M", "II",
                "II", "II"
            },
                    new string[] {
                "A", "B", "C", "JJ", "G", "A", "II", "KK", "A", "B", "C", "D",
                "E", "F", "G", "A", "H", "I", "J", "D", "K", "L", "C", "G", "M",
                "H", "N", "J", "I", "K", "O", "C", "G", "M", "P", "Q", "J", "R",
                "K", "S", "C", "C", "F", "G", "D", "TKey", "N", "G", "M", "U", "V",
                "J", "Q", "K", "W", "C", "G", "M", "X", "C", "V", "K", "Y", "C",
                "G", "G", "A", "Z", "AA", "J", "C", "Z", "G", "V", "K", "BB", "C",
                "G", "M", "CC", "DD", "J", "EE", "K", "FF", "C", "AA", "G", "M",
                "GG", "K", "HH", "C", "DD", "G", "M", "II", "II", "II", "II"
            });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateCopy(0, 2),
                PatchOperation.CreateAddition(3, 10),
                PatchOperation.CreateCopy(3, 87),
                PatchOperation.CreateAddition(96, 96),
                PatchOperation.CreateCopy(88, 90)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
Exemplo n.º 11
0
        public void GetPatchOperations()
        {
            DiffEngine <string> diffEngine =
                new DiffEngine <string>(
                    new string[] { "a", "b", "c", "e", "h", "j", "l", "m", "n", "p" },
                    new string[] { "b", "c", "d", "e", "f", "j", "k", "l", "m", "r", "s", "t" });

            PatchOperation[] expectedPatchOperations =
                new PatchOperation[] {
                PatchOperation.CreateDeletion(0, 0),
                PatchOperation.CreateCopy(1, 2),
                PatchOperation.CreateAddition(2, 2),
                PatchOperation.CreateCopy(3, 3),
                PatchOperation.CreateAddition(4, 4),
                PatchOperation.CreateDeletion(4, 4),
                PatchOperation.CreateCopy(5, 5),
                PatchOperation.CreateAddition(6, 6),
                PatchOperation.CreateCopy(6, 7),
                PatchOperation.CreateAddition(9, 11),
                PatchOperation.CreateDeletion(8, 9)
            };

            AssertDifferences(diffEngine, expectedPatchOperations);
        }
 public void CopyDifferenceDoesNotAllowGetDeletionProperty()
 {
     PatchOperation patchOperation = PatchOperation.CreateCopy(new Range <int>(10, 15));
     Range <int>    range          = patchOperation.Deletion;
 }
        public void CopyDifferenceDoesNotAllowSetAdditionProperty()
        {
            PatchOperation patchOperation = PatchOperation.CreateCopy(new Range <int>(10, 15));

            patchOperation.Addition = new Range <int>();
        }