示例#1
0
        private void ReloadFiles()
        {
            string[] files = Directory.GetFiles(Application.StartupPath + "/XmlPatches", "*.xml", SearchOption.TopDirectoryOnly);

            lsb_FilesList.SelectedIndices.Clear();

            clb_Patches.Items.Clear();
            ClearCurrentPatch();

            Patchlist = new PatchList(files, asmUtility);
            //Patchlist.AllCheckedPatches = clb_Patches.CheckedItems;

            lsb_FilesList.Items.Clear();
            lsb_FilesList.Items.Add("All");
            lsb_FilesList.SelectedIndices.Clear();
            //LoadFile(files[lsb_FilesList.FocusedItem.Index]);
            for (int i = 0; i < files.Length; i++)
            {
                files[i] = files[i].Substring(files[i].LastIndexOf("\\") + 1);
                lsb_FilesList.Items.Add(files[i]);

                if(!Patchlist.LoadedCorrectly[i])
                    lsb_FilesList.Items[i + 1].BackColor = Color.Red;
            }
            //LoadFiles( files );

            numberoffiles = files.Length;

            //lsb_FilesList.SelectedIndices.Add(0);
        }
        public void FromTextTest1()
        {
            var strp = "@@ -21,18 +22,17 @@\n jump\n-s\n+ed\n  over \n-the\n+a\n %0alaz\n";

            Assert.AreEqual(strp, PatchList.Parse(strp)[0].ToString(), "patch_fromText: #1.");
        }
 public void FromTextTest2()
 {
     Assert.AreEqual("@@ -1 +1 @@\n-a\n+b\n", PatchList.Parse("@@ -1 +1 @@\n-a\n+b\n")[0].ToString(),
                     "patch_fromText: #2.");
 }
        public void Parse_EmptyString_YieldsEmptyList()
        {
            var patches = PatchList.Parse("");

            Assert.IsFalse(patches.Any());
        }
        public void Test__Lifecycle()
        {
            IPatch[] patches = new IPatch[]
            {
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
                Substitute.For <IPatch>(),
            };

            UrlDir.UrlConfig urlConfig = UrlBuilder.CreateConfig("abc/def", new ConfigNode("NODE"));

            patches[00].PassSpecifier.Returns(new FirstPassSpecifier());
            patches[01].PassSpecifier.Returns(new FirstPassSpecifier());
            patches[02].PassSpecifier.Returns(new LegacyPassSpecifier());
            patches[03].PassSpecifier.Returns(new LegacyPassSpecifier());
            patches[04].PassSpecifier.Returns(new BeforePassSpecifier("mod1", urlConfig));
            patches[05].PassSpecifier.Returns(new BeforePassSpecifier("MOD1", urlConfig));
            patches[06].PassSpecifier.Returns(new ForPassSpecifier("mod1", urlConfig));
            patches[07].PassSpecifier.Returns(new ForPassSpecifier("MOD1", urlConfig));
            patches[08].PassSpecifier.Returns(new AfterPassSpecifier("mod1", urlConfig));
            patches[09].PassSpecifier.Returns(new AfterPassSpecifier("MOD1", urlConfig));
            patches[10].PassSpecifier.Returns(new BeforePassSpecifier("mod2", urlConfig));
            patches[11].PassSpecifier.Returns(new BeforePassSpecifier("MOD2", urlConfig));
            patches[12].PassSpecifier.Returns(new ForPassSpecifier("mod2", urlConfig));
            patches[13].PassSpecifier.Returns(new ForPassSpecifier("MOD2", urlConfig));
            patches[14].PassSpecifier.Returns(new AfterPassSpecifier("mod2", urlConfig));
            patches[15].PassSpecifier.Returns(new AfterPassSpecifier("MOD2", urlConfig));
            patches[16].PassSpecifier.Returns(new FinalPassSpecifier());
            patches[17].PassSpecifier.Returns(new FinalPassSpecifier());

            IPatchProgress progress = Substitute.For <IPatchProgress>();

            PatchList patchList = new PatchList(new[] { "mod1", "mod2" }, patches, progress);

            IPass[] passes = patchList.ToArray();

            Assert.Equal(":FIRST", passes[0].Name);
            Assert.Equal(new[] { patches[0], patches[1] }, passes[0]);

            Assert.Equal(":LEGACY (default)", passes[1].Name);
            Assert.Equal(new[] { patches[2], patches[3] }, passes[1]);

            Assert.Equal(":BEFORE[MOD1]", passes[2].Name);
            Assert.Equal(new[] { patches[4], patches[5] }, passes[2]);

            Assert.Equal(":FOR[MOD1]", passes[3].Name);
            Assert.Equal(new[] { patches[6], patches[7] }, passes[3]);

            Assert.Equal(":AFTER[MOD1]", passes[4].Name);
            Assert.Equal(new[] { patches[8], patches[9] }, passes[4]);

            Assert.Equal(":BEFORE[MOD2]", passes[5].Name);
            Assert.Equal(new[] { patches[10], patches[11] }, passes[5]);

            Assert.Equal(":FOR[MOD2]", passes[6].Name);
            Assert.Equal(new[] { patches[12], patches[13] }, passes[6]);

            Assert.Equal(":AFTER[MOD2]", passes[7].Name);
            Assert.Equal(new[] { patches[14], patches[15] }, passes[7]);

            Assert.Equal(":FINAL", passes[8].Name);
            Assert.Equal(new[] { patches[16], patches[17] }, passes[8]);

            progress.Received(patches.Length).PatchAdded();
        }
示例#6
0
 public void Parse_WhenBadPatch_Throws()
 {
     PatchList.Parse("Bad\nPatch\n");
 }
示例#7
0
 public void FromTextTest4()
 {
     Assert.AreEqual("@@ -0,0 +1,3 @@\n+abc\n", PatchList.Parse("@@ -0,0 +1,3 @@\n+abc\n")[0].ToString(),
                     "patch_fromText: #4.");
 }
示例#8
0
 public void FromTextTest3()
 {
     Assert.AreEqual("@@ -1,3 +0,0 @@\n-abc\n", PatchList.Parse("@@ -1,3 +0,0 @@\n-abc\n")[0].ToString(),
                     "patch_fromText: #3.");
 }