public void TestExtractPatch__Insert()
        {
            UrlDir.UrlConfig urlConfig = CreateConfig("NODE_TYPE");

            ITagList tagList = Substitute.For <ITagList>();

            tagListParser.Parse("NODE_TYPE", urlConfig).Returns(tagList);

            IPassSpecifier passSpecifier = Substitute.For <IPassSpecifier>();
            ProtoPatch     protoPatch    = new ProtoPatch(
                urlConfig,
                Command.Insert,
                "NODE_TYPE",
                null,
                "needs",
                null,
                passSpecifier
                );

            protoPatchBuilder.Build(urlConfig, Command.Insert, tagList).Returns(protoPatch);
            needsChecker.CheckNeedsExpression("needs").Returns(true);
            passSpecifier.CheckNeeds(needsChecker, progress).Returns(true);

            ConfigNode needsCheckedNode = null;

            needsChecker.CheckNeedsRecursive(Arg.Do <ConfigNode>(node => needsCheckedNode = node), urlConfig);

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

            AssertNoErrors();

            Received.InOrder(delegate
            {
                tagListParser.Parse("NODE_TYPE", urlConfig);
                protoPatchBuilder.Build(urlConfig, Command.Insert, tagList);
                needsChecker.CheckNeedsExpression("needs");
                passSpecifier.CheckNeeds(needsChecker, progress);
                needsChecker.CheckNeedsRecursive(needsCheckedNode, urlConfig);
            });

            patchCompiler.DidNotReceiveWithAnyArgs().CompilePatch(null);

            Assert.Equal(1, root.AllConfigs.Count());
            UrlDir.UrlConfig newUrlConfig = root.AllConfigs.First();
            Assert.NotSame(urlConfig, newUrlConfig);
            Assert.NotSame(urlConfig.config, newUrlConfig.config);
            AssertConfigNodesEqual(urlConfig.config, newUrlConfig.config);
            Assert.Same(needsCheckedNode, newUrlConfig.config);

            progress.DidNotReceiveWithAnyArgs().NeedsUnsatisfiedRoot(null);
        }
        public void TestExtractPatch__NeedsUnsatisfiedPassSpecifier()
        {
            UrlDir.UrlConfig urlConfig = CreateConfig("@NODE_TYPE");

            ITagList tagList = Substitute.For <ITagList>();

            tagListParser.Parse("NODE_TYPE", urlConfig).Returns(tagList);

            IPassSpecifier passSpecifier = Substitute.For <IPassSpecifier>();
            ProtoPatch     protoPatch    = new ProtoPatch(
                urlConfig,
                Command.Edit,
                "NODE_TYPE",
                "nodeName",
                "needs",
                "has",
                passSpecifier
                );

            protoPatchBuilder.Build(urlConfig, Command.Edit, tagList).Returns(protoPatch);
            needsChecker.CheckNeedsExpression("needs").Returns(true);
            passSpecifier.CheckNeeds(needsChecker, progress).Returns(false);

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

            AssertNoErrors();

            Assert.Empty(root.AllConfigs);

            needsChecker.DidNotReceiveWithAnyArgs().CheckNeedsRecursive(null, null);
            patchCompiler.DidNotReceiveWithAnyArgs().CompilePatch(null);

            progress.DidNotReceiveWithAnyArgs().NeedsUnsatisfiedRoot(null);
        }