public void CreateAddition()
        {
            PatchOperation patchOperation = PatchOperation.CreateAddition(new Range <int>(10, 15));

            Assert.AreEqual(PatchOperationType.Addition, patchOperation.Type);
            Assert.AreEqual(new Range <int>(10, 15), patchOperation.Addition);
        }
示例#2
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 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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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 AdditionDifferenceDoesNotAllowSetCopyProperty()
        {
            PatchOperation patchOperation = PatchOperation.CreateAddition(new Range <int>(10, 15));

            patchOperation.Copy = new Range <int>();
        }
 public void AdditionDifferenceDoesNotAllowGetDeletionProperty()
 {
     PatchOperation patchOperation = PatchOperation.CreateAddition(new Range <int>(10, 15));
     Range <int>    range          = patchOperation.Deletion;
 }