Exemplo n.º 1
0
        public void AddLinkTwice()
        {
            var            dict    = BuildTestTree();
            AddLinkCommand command = new AddLinkCommand(new NullDb(), dict["Node 1.1"], dict["Node 2.2"], true);

            command.Execute();
        }
Exemplo n.º 2
0
        public void Execute_WithOnlyRequiredArgumentsRunTwice_ShouldShowDuplicatePathErrorMessage()
        {
            // Arrange
            const string testPath       = @"c:/config.linker";
            const string testSourcePath = @"c:/demo/";
            const string testTargetPath = "testTargetDirectory";

            AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, ConfigLink.LinkType.Default, testPath);

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

            // Act
            testConsole.ShouldRecordHistory = false;
            command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter);

            testConsole.ShouldRecordHistory = true;
            command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter);

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("already exists", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(testConsole.GetHistory().Contains(testTargetPath, StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void Execute_WithInvalidSourceFolder_ShouldShowInvalidPathErrorMessage()
        {
            // Arrange
            const string testPath       = @"c:/config.linker";
            const string testSourcePath = @"c:/some path that does not exist";
            const string testTargetPath = "testTargetDirectory";

            AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, ConfigLink.LinkType.Default, testPath);

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

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

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("does not exist", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(testConsole.GetHistory().Contains(testSourcePath, StringComparison.OrdinalIgnoreCase));
        }
Exemplo n.º 5
0
        public void Execute_WithLinkFlagJunction_ShouldCreateJunctionLink()
        {
            // Arrange
            const string testPath                  = @"c:/config.linker";
            const string testSourcePath            = @"c:/demo/";
            const string testTargetPath            = @"c:/folder/anotherfolder/yetanotherfolder";
            const ConfigLink.LinkType testLinkType = ConfigLink.LinkType.Junction;

            AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, testLinkType, testPath);

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

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

            // Assert
            Assert.IsTrue(testConfigHandler.Object.LoadConfig(testPath).LinkList.Any(link =>
                                                                                     link.sourcePath.Equals(testSourcePath) && link.targetPath.Equals(testTargetPath) && link.linkType == testLinkType));
        }
Exemplo n.º 6
0
        public void Execute_WithOnlyRequiredArguments_WillCreateDefaultDirectoryLink()
        {
            // Arrange
            const string testPath       = @"c:/config.linker";
            const string testSourcePath = @"c:/demo/";
            const string testTargetPath = "testTargetDirectory";

            AddLinkCommand command = new AddLinkCommand(testSourcePath, testTargetPath, ConfigLink.LinkType.Default, 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, testPathFormatter);

            // Assert
            Assert.IsTrue(testConfigHandler.Object.LoadConfig(testPath).LinkList.Any(link =>
                                                                                     link.sourcePath.Equals(testSourcePath) && link.targetPath.Equals(testTargetPath) && link.linkType == ConfigLink.LinkType.Default));
        }