Пример #1
0
        public void TestLoadPatch()
        {
            PatchManager manager = NewManager();

            TestPatch expectedPatch = new TestPatch();
            Encoding  fileEncoding  = Encoding.UTF8;

            expectedPatch.Patch.Type        = Patch.PatchType.ChangeFile;
            expectedPatch.Patch.Apply       = true;
            expectedPatch.Patch.PatchHeader = "diff --git a/thisisatest.txt b/thisisatest.txt";
            expectedPatch.Patch.PatchIndex  = "index 5e4dce2..5eb1e6f 100644";
            expectedPatch.Patch.FileNameA   = "thisisatest.txt";
            expectedPatch.Patch.FileNameB   = "thisisatest.txt";
            expectedPatch.AppendHeaderLine(expectedPatch.Patch.PatchHeader);
            expectedPatch.AppendHeaderLine(expectedPatch.Patch.PatchIndex);
            expectedPatch.AppendHeaderLine("--- a/" + expectedPatch.Patch.FileNameA);
            expectedPatch.AppendHeaderLine("+++ b/" + expectedPatch.Patch.FileNameB);
            expectedPatch.AppendDiffLine("@@ -1,2 +1,2 @@", fileEncoding);
            expectedPatch.AppendDiffLine(" iiiiii", fileEncoding);
            expectedPatch.AppendDiffLine("-ąśdkjaldskjlaksd", fileEncoding);
            expectedPatch.AppendDiffLine("+changed again€", fileEncoding);

            manager.LoadPatch(expectedPatch.PatchOutput.ToString(), false, fileEncoding);

            Patch createdPatch = manager.Patches.First();

            Assert.AreEqual(expectedPatch.Patch.Text, createdPatch.Text);
        }
Пример #2
0
        public void TestLoadPatch()
        {
            PatchManager manager = NewManager();

            TestPatch expectedPatch = new TestPatch();
            Encoding fileEncoding = Encoding.UTF8;
            expectedPatch.Patch.Type = Patch.PatchType.ChangeFile;
            expectedPatch.Patch.Apply = true;
            expectedPatch.Patch.PatchHeader = "diff --git a/thisisatest.txt b/thisisatest.txt";
            expectedPatch.Patch.PatchIndex = "index 5e4dce2..5eb1e6f 100644";
            expectedPatch.Patch.FileNameA = "thisisatest.txt";
            expectedPatch.Patch.FileNameB = "thisisatest.txt";
            expectedPatch.AppendHeaderLine(expectedPatch.Patch.PatchHeader);
            expectedPatch.AppendHeaderLine(expectedPatch.Patch.PatchIndex);
            expectedPatch.AppendHeaderLine("--- a/" + expectedPatch.Patch.FileNameA);
            expectedPatch.AppendHeaderLine("+++ b/" + expectedPatch.Patch.FileNameB);
            expectedPatch.AppendDiffLine("@@ -1,2 +1,2 @@", fileEncoding);
            expectedPatch.AppendDiffLine(" iiiiii", fileEncoding);
            expectedPatch.AppendDiffLine("-ąśdkjaldskjlaksd", fileEncoding);
            expectedPatch.AppendDiffLine("+changed again€", fileEncoding);

            manager.LoadPatch(expectedPatch.PatchOutput.ToString(), false, fileEncoding);

            Patch createdPatch = manager.Patches.First();
            Assert.AreEqual(expectedPatch.Patch.Text, createdPatch.Text);
        }