Ejemplo n.º 1
0
        public void Execute_WithNoLoops_WillFindNoLoops()
        {
            // Arrange
            ScanCommand command = new ScanCommand(@"c:/demo", 5, false, false);

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

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("no loops found", StringComparison.OrdinalIgnoreCase));
        }
Ejemplo n.º 2
0
        public void Execute_WithEmptyConfig_ShouldPrintConfigEmpty()
        {
            // Arrange
            ListCommand command = new ListCommand(false, "testpath");

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

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

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("empty", StringComparison.OrdinalIgnoreCase));
        }
Ejemplo n.º 3
0
        public void Execute_WithNoConfig_ShouldPrintError()
        {
            // Arrange
            AddLinksCommand command = new AddLinksCommand("c:/", ".", ConfigLink.LinkType.Default, @"[\s\S]*", @"[\s\S]*", false, false, null);

            testConfigHandler.Setup(m => m.DoesConfigExist(It.IsAny <string> ())).Returns(false);

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

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("does not exist", StringComparison.OrdinalIgnoreCase));
        }
        public void Execute_WithValidConfig_WillPrintValidConfig()
        {
            // Arrange
            ValidateCommand command = new ValidateCommand(false, "testpath");

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

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

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("100% valid", System.StringComparison.OrdinalIgnoreCase));
        }
Ejemplo n.º 5
0
        public void Execute_WithOnlyPathFlag_WillPrintTotalLinks()
        {
            // Arrange
            string        testPath = testFileSystem.AllFiles.First();
            ConfigCommand command  = new ConfigCommand(false, false, testPath);

            testLinks.Add(testLinkElements[0]);

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

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

            // Assert
            Assert.IsTrue(testConsole.GetHistory().Contains("Total links: " + testLinks.Count));
        }
        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));
        }
Ejemplo n.º 7
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));
        }