public void Execute_WithInvalidRegex_ShouldPrintError() { // Arrange AddLinksCommand command = new AddLinksCommand("c:/", "", ConfigLink.LinkType.Default, "[", "", false, false, ""); // Act command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter); // Assert Assert.IsTrue(testConsole.GetHistory().Contains("regex", StringComparison.OrdinalIgnoreCase)); Assert.IsTrue(testConsole.GetHistory().Contains("invalid", StringComparison.OrdinalIgnoreCase)); }
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_NonRecursiveFiles(string fileName, bool shouldExist) { // Arrange AddLinksCommand command = new AddLinksCommand("c:/", ".", ConfigLink.LinkType.Default, @"[\s\S]*", @"[\s\S]*", false, false, null); // Act command.Execute(testConsole, testConfigHandler.Object, testFileSystem, testPathFormatter); // Assert if (shouldExist) { Assert.IsTrue(testLinks.Any(link => link.sourcePath.EndsWith("c:/" + fileName) && link.targetPath.EndsWith("./" + fileName))); } else { Assert.IsFalse(testLinks.Any(link => link.sourcePath.EndsWith("c:/" + fileName) && link.targetPath.EndsWith("./" + fileName))); } }