public void TestSortAndExtractPatches__InsertWithPass()
        {
            UrlDir.UrlConfig config1 = CreateConfig("NODE");
            UrlDir.UrlConfig config2 = CreateConfig("NODE:FOR[mod1]");
            UrlDir.UrlConfig config3 = CreateConfig("NODE:FOR[mod2]");
            UrlDir.UrlConfig config4 = CreateConfig("NODE:FINAL");

            string[]  modList = { "mod1" };
            PatchList list    = PatchExtractor.SortAndExtractPatches(root, modList, progress);

            Assert.Equal(new[] { config1 }, root.AllConfigs);

            progress.Received().Error(config2, "Error - pass specifier detected on an insert node (not a patch): abc/def/NODE:FOR[mod1]");
            progress.Received().Error(config3, "Error - pass specifier detected on an insert node (not a patch): abc/def/NODE:FOR[mod2]");
            progress.Received().Error(config4, "Error - pass specifier detected on an insert node (not a patch): abc/def/NODE:FINAL");

            Assert.Empty(list.firstPatches);
            Assert.Empty(list.legacyPatches);
            Assert.Empty(list.finalPatches);
            Assert.Empty(list.modPasses["mod1"].beforePatches);
            Assert.Empty(list.modPasses["mod1"].forPatches);
            Assert.Empty(list.modPasses["mod1"].afterPatches);

            progress.DidNotReceive().PatchAdded();
        }
        public void TestExtractPatch__ProtoPatchNull()
        {
            UrlDir.UrlConfig patchConfig = UrlBuilder.CreateConfig("abc/def", new ConfigNode("NODE"), root);

            protoPatchBuilder.Build(patchConfig, Command.Insert, Arg.Any <ITagList>()).Returns(null, new ProtoPatch[0]);

            Assert.Null(patchExtractor.ExtractPatch(patchConfig));

            needsChecker.DidNotReceiveWithAnyArgs().CheckNeedsExpression(null);

            AssertNoErrors();

            progress.DidNotReceive().PatchAdded();
            progress.DidNotReceiveWithAnyArgs().NeedsUnsatisfiedRoot(null);
        }
Example #3
0
        public void TestConstructor__UnknownMod()
        {
            IPatch patch = Substitute.For <IPatch>();

            UrlDir.UrlConfig urlConfig = UrlBuilder.CreateConfig("abc/def", new ConfigNode("NODE"));
            patch.PassSpecifier.Returns(new BeforePassSpecifier("mod3", urlConfig));
            IPatchProgress progress = Substitute.For <IPatchProgress>();

            KeyNotFoundException ex = Assert.Throws <KeyNotFoundException>(delegate
            {
                new PatchList(new[] { "mod1", "mod2" }, new[] { patch }, progress);
            });

            Assert.Equal("Mod 'mod3' not found", ex.Message);

            progress.DidNotReceive().PatchAdded();
        }
Example #4
0
        public void TestConstructor__UnknownPassSpecifier()
        {
            IPatch patch = Substitute.For <IPatch>();

            UrlDir.UrlConfig urlConfig     = UrlBuilder.CreateConfig("abc/def", new ConfigNode("NODE"));
            IPassSpecifier   passSpecifier = Substitute.For <IPassSpecifier>();

            passSpecifier.Descriptor.Returns(":SOMEPASS");
            patch.PassSpecifier.Returns(passSpecifier);
            IPatchProgress progress = Substitute.For <IPatchProgress>();

            NotImplementedException ex = Assert.Throws <NotImplementedException>(delegate
            {
                new PatchList(new string[0], new[] { patch }, progress);
            });

            Assert.Equal("Don't know what to do with pass specifier: :SOMEPASS", ex.Message);

            progress.DidNotReceive().PatchAdded();
        }