Ejemplo n.º 1
0
        public void RemoveLinkUndoBeforeExecute()
        {
            var dict = BuildTestTree();

            new AddLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"], true);
            RemoveLinkCommand command = new RemoveLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"]);

            command.Undo();
        }
Ejemplo n.º 2
0
        public void RemoveLastLinkOfMiddleNode()
        {
            var dict = BuildTestTree();
            IRootCauseCommand command = new RemoveLinkCommand(new NullDb(), dict["Problem"], dict["Node 1"], true);

            Assert.AreEqual("Problem,Node 2,Node 2.1,Node 2.1.1,Node 2.2", StringifyTree(dict["Problem"]));
            command.Undo();
            Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"]));
        }
Ejemplo n.º 3
0
        public void RemoveLinkAndUndo()
        {
            var dict = BuildTestTree();

            new AddLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"], true);
            RemoveLinkCommand command = new RemoveLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"]);

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