コード例 #1
0
        public void AddLinkUndoBeforeExecute()
        {
            var            dict    = BuildTestTree();
            AddLinkCommand command = new AddLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"]);

            command.Undo();
        }
コード例 #2
0
        public void AddLinkAndUndo()
        {
            var            dict    = BuildTestTree();
            AddLinkCommand command = new AddLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"]);

            Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"]));
            Assert.AreEqual(1, dict["Node 2.2"].CountParentNodes());
            command.Execute();
            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(true, command.Executed);
            command.Undo();
            Assert.AreEqual(1, dict["Node 2.2"].CountParentNodes());
            Assert.AreEqual(defaultTestTree, StringifyTree(dict["Problem"]));
            Assert.AreEqual(false, command.Executed);
        }