Beispiel #1
0
        public void RemoveNodeAndUndo()
        {
            var dict = BuildTestTree();
            IRootCauseCommand command = new RemoveNodeCommand(new NullDb(), dict["Node 1"]);

            Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"]));
            command.Execute();
            foreach (var node in new Node[] { dict["Node 1.1"], dict["Node 1.2"] })
            {
                Assert.AreEqual(1, node.CountParentNodes());
                foreach (var parent in node.ParentNodes)
                {
                    Assert.AreEqual("Problem", parent.Text);
                }
            }

            Assert.AreEqual(3, dict["Problem"].CountChildNodes());
            foreach (var node in dict["Problem"].ChildNodes)
            {
                Assert.IsTrue("Node 1.1,Node 1.2,Node 2".Contains(node.Text));
            }
            Assert.AreEqual(true, command.Executed);

            command.Undo();
            Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"]));
            Assert.AreEqual(false, command.Executed);
        }
Beispiel #2
0
        public void RemoveNodeTwice()
        {
            var dict = BuildTestTree();
            IRootCauseCommand command = new RemoveNodeCommand(new NullDb(), dict["Node 1"], true);

            command.Execute();
        }
        public void RemovingNodeOnSceneShouldResultInRemovingFromInRepo()
        {
            var      node    = testModel.CreateElement(testNodeType);
            ICommand command = new RemoveNodeCommand(model, node);

            command.Execute();

            Assert.Zero(testModel.Nodes.Count());
        }
        public void TwoNodesShareTheSameConfigurationAndIncludeTypeRemoveOneIncludeTypeRemains()
        {
            AddConfigurationSectionCommand cmd = new AddConfigurationSectionCommand(Host, typeof(MyConfigurationNode), section);
            cmd.Execute(GeneratedApplicationNode);
            cmd.Execute(GeneratedApplicationNode);
            ConfigurationNode secondAddedNode = cmd.ChildNode;

            RemoveNodeCommand removeNodeCommand = new RemoveNodeCommand(Host);
            removeNodeCommand.Execute(secondAddedNode);

            ConfigurationSectionCollectionNode node = (ConfigurationSectionCollectionNode)GeneratedHierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode));
            Assert.IsNotNull(node);
            ConfigurationSectionNode sectionNode = (ConfigurationSectionNode)GeneratedHierarchy.FindNodeByName(node, section);
            ConfigurationNode[] types = GeneratedHierarchy.FindNodesByType(sectionNode, typeof(XmlIncludeTypeNode));
            Assert.AreEqual(1, types.Length);
            XmlIncludeTypeNode xmlIncludeTypeNode = types[0] as XmlIncludeTypeNode;
            Assert.IsNotNull(xmlIncludeTypeNode);
            Assert.AreEqual(xmlIncludeTypeNode.Name, typeof(MyConfigurationData).Name);
        }
        public void TwoNodesShareTheSameConfigurationAndIncludeTypeRemoveOneIncludeTypeRemains()
        {
            AddConfigurationSectionCommand cmd = new AddConfigurationSectionCommand(Host, typeof(MyConfigurationNode), section);

            cmd.Execute(GeneratedApplicationNode);
            cmd.Execute(GeneratedApplicationNode);
            ConfigurationNode secondAddedNode = cmd.ChildNode;

            RemoveNodeCommand removeNodeCommand = new RemoveNodeCommand(Host);

            removeNodeCommand.Execute(secondAddedNode);

            ConfigurationSectionCollectionNode node = (ConfigurationSectionCollectionNode)GeneratedHierarchy.FindNodeByType(typeof(ConfigurationSectionCollectionNode));

            Assert.IsNotNull(node);
            ConfigurationSectionNode sectionNode = (ConfigurationSectionNode)GeneratedHierarchy.FindNodeByName(node, section);

            ConfigurationNode[] types = GeneratedHierarchy.FindNodesByType(sectionNode, typeof(XmlIncludeTypeNode));
            Assert.AreEqual(1, types.Length);
            XmlIncludeTypeNode xmlIncludeTypeNode = types[0] as XmlIncludeTypeNode;

            Assert.IsNotNull(xmlIncludeTypeNode);
            Assert.AreEqual(xmlIncludeTypeNode.Name, typeof(MyConfigurationData).Name);
        }