Exemple #1
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"]));
        }
Exemple #2
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();
        }
        public void Execute_WithInvalidTargetPath_WillPrintError()
        {
            // Arrange
            const string      testTargetPath = "some random target here";
            RemoveLinkCommand command        = new RemoveLinkCommand(testTargetPath, "testpath");

            testLinks.Add(testLinkElements[0]);
            testLinks.Add(testLinkElements[1]);
            testConfigHandler.Setup(m => m.LoadConfig("testpath")).Returns(testConfig.Object);

            // Act
            command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathResolver);

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("does not exist", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(testConsole.GetHistory().Contains(testTargetPath));
        }
        public void Execute_WithTargetPath_WillRemoveFromConfig()
        {
            // Arrange
            RemoveLinkCommand command = new RemoveLinkCommand("target", "testpath");

            testLinks.Add(testLinkElements[0]);
            testLinks.Add(testLinkElements[1]);

            testConfigHandler.Setup(m => m.LoadConfig("testpath")).Returns(testConfig.Object);

            // Act
            command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathResolver);

            // Assert
            Assert.IsFalse(testConfigHandler.Object.LoadConfig("testpath").LinkList.Contains(testLinkElements[0]));
            Assert.IsTrue(testConfigHandler.Object.LoadConfig("testpath").LinkList.Contains(testLinkElements[1]));
        }
Exemple #5
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);
        }