예제 #1
0
        public void MoveNodeMultipleParentsAndUndo()
        {
            string startStr = "Problem,Node 1,Node 1.1,Node 1.2,I have multiple parents!,Node 2,Node 2.1,Node 2.1.1,Node 2.2,I have multiple parents!";
            var    dict     = BuildTestTree();
            Node   node     = new AddNodeCommand(new NullDb(), dict["Node 1"], "I have multiple parents!", true).NewNode;

            new AddLinkCommand(new NullDb(), dict["Node 2"], node, true);
            Assert.AreEqual(startStr, StringifyTree(dict["Problem"]));
            Assert.AreEqual(2, node.CountParentNodes());
            Assert.AreEqual(3, dict["Node 1"].CountChildNodes());
            Assert.AreEqual(3, dict["Node 2"].CountChildNodes());

            IRootCauseCommand command = new MoveNodeCommand(new NullDb(), node, dict["Problem"], true);

            Assert.AreEqual("Problem,Node 1,Node 1.1,Node 1.2,Node 2,Node 2.1,Node 2.1.1,Node 2.2,I have multiple parents!", StringifyTree(dict["Problem"]));
            Assert.AreEqual(1, node.CountParentNodes());
            Assert.AreEqual(2, dict["Node 1"].CountChildNodes());
            Assert.AreEqual(2, dict["Node 2"].CountChildNodes());

            command.Undo();
            Assert.AreEqual(startStr, StringifyTree(dict["Problem"]));
            Assert.AreEqual(2, node.CountParentNodes());
            Assert.AreEqual(3, dict["Node 1"].CountChildNodes());
            Assert.AreEqual(3, dict["Node 2"].CountChildNodes());
        }
예제 #2
0
        public void MoveNodeChainTwice()
        {
            var dict    = BuildTestTree();
            var command = new MoveNodeCommand(new NullDb(), dict["Node 1"], dict["Node 2"], true);

            command.Execute();
        }
예제 #3
0
        public void MoveNodeChainUndoBeforeExecute()
        {
            var dict    = BuildTestTree();
            var command = new MoveNodeCommand(new NullDb(), dict["Node 1"], dict["Node 2"]);

            command.Undo();
        }
예제 #4
0
        public void MoveNodeAndUndo()
        {
            var dict    = BuildTestTree();
            var command = new MoveNodeCommand(new NullDb(), dict["Node 1"], dict["Node 2"]);

            Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"]));
            command.Execute();
            Assert.AreEqual("Problem,Node 2,Node 1,Node 1.1,Node 1.2,Node 2.1,Node 2.1.1,Node 2.2", StringifyTree(dict["Problem"]));
            Assert.AreEqual(true, command.Executed);
            command.Undo();
            Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"]));
            Assert.AreEqual(false, command.Executed);
        }