public void GetDirectories_WhenPathFoundButThereIsNoDirectories_ReturnsEmpty() { //Arrange PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem); string path = Path.Combine(_userFolder, "Exist"); _fileSystemMock .Setup(fs => fs.DirectoryExists( It.Is <string>(s => s == path)) ) .Returns(true); _fileSystemMock .Setup( fs => fs.GetDirectories( It.Is <string>(s => s == path), It.IsAny <string>() ) ) .Returns(new List <string>()); //Act var result = creator.GetDirectories(path, "FilterNotExists"); //Assert Assert.Empty(result); _fileSystemMock.VerifyAll(); }
public void Split_WhenSomePathIsNull_ReturnsException(string fullPath, string mainPath) { //Arrange PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem); //Act Action result = () => creator.Split(fullPath, mainPath); //Assert Assert.Throws <ArgumentException>(result); }
public void Split_WhenCalls_ReturnsTruncatedPath(string expected, string fullPath, string mainPath) { //Arrange PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem); //Act var result = creator.Split(fullPath, mainPath); //Assert Assert.Equal(expected, result); }
public void GetFileName_WhenFilePathIsNull_ReturnsException() { //Arrange PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem); //Act Action result = () => creator.GetFileName(null); //Assert Assert.Throws <ArgumentException>(result); }
static void Main(string[] args) { try { _disk = new DiskConfigurator(FileSystem.Default); switch (OS.GetCurrent()) { case "win": _path = new PathsConfigurator(CommandSystem.Win, FileSystem.Default); break; case "mac": _path = new PathsConfigurator(CommandSystem.Mac, FileSystem.Default); break; } _notificationSystem = NotificationSystem.Default; switch (OS.GetCurrent()) { case "win": _bridgeSystem = BridgeSystem.Bat; _colorify = new Format(Theme.Dark); break; case "gnu": _bridgeSystem = BridgeSystem.Bash; _colorify = new Format(Theme.Dark); break; case "mac": _bridgeSystem = BridgeSystem.Bash; _colorify = new Format(Theme.Light); break; } _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem); Menu(); _colorify.ResetColor(); _colorify.Clear(); } catch (ArgumentOutOfRangeException) { MessageException("Ahh my eyes! Why this console is too small?"); } catch (Exception ex) { MessageException(ex.ToString()); } }
public void GetDirectories_WhenPathNotFound_ReturnsException() { //Arrange PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem); string path = Path.Combine(_userFolder, "NotExist"); _fileSystemMock .Setup(fs => fs.DirectoryExists( It.Is <string>(s => s == path)) ) .Returns(false); //Act Action result = () => creator.GetDirectories(path, null); //Assert Assert.Throws <DirectoryNotFoundException>(result); _fileSystemMock.VerifyAll(); }
private static void Factory() { _fileSystem = FileSystem.Default; _notificationSystem = new ConsoleNotificationSystem(); _disk = new DiskConfigurator(_fileSystem, _notificationSystem); switch (OS.GetCurrent()) { case "win": _path = new PathsConfigurator(CommandSystem.Win, _fileSystem); _bridgeSystem = BridgeSystem.Bat; _colorify = new Format(Theme.Dark); break; case "mac": _path = new PathsConfigurator(CommandSystem.Mac, _fileSystem); _bridgeSystem = BridgeSystem.Bash; _colorify = new Format(Theme.Light); break; } _shell = new ShellConfigurator(_bridgeSystem, _notificationSystem); _logSystem = new FileLogTxt(_fileSystem, _path.Combine("~"), ".hardhat.log"); }
public void GetFiles_WhenCalls_ReturnsFileList(string[] expectedResult, string path, string filter) { //Arrange PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem); path = Path.Combine(_userFolder, path); _fileSystemMock .Setup(fs => fs.DirectoryExists( It.Is <string>(s => s == path)) ) .Returns(true); _fileSystemMock .Setup(fs => fs.GetFiles(path, It.IsAny <string>(), It.IsAny <SearchOption>())) .Returns(expectedResult); //Act var result = creator.GetFiles(path, filter); //Assert Assert.Equal(expectedResult, result); _fileSystemMock.VerifyAll(); }
public void Combine_WhenCalls_ReturnsCombinedPath(string expected, params string[] paths) { //Arrange PathsConfigurator creator = new PathsConfigurator(_commandSystem, _fileSystem); string expectedResult = Path.Combine(paths); _fileSystemMock .Setup(fs => fs.PathCombine(It.IsAny <string[]>())) .Returns(expectedResult); expectedResult = Path.Combine(_userFolder, expected); _commandSystemMock .Setup(cs => cs.GetHomeFolder(It.IsAny <string>())) .Returns(expectedResult); //Act var result = creator.Combine(paths); //Assert Assert.Equal(expectedResult, result); _fileSystemMock.VerifyAll(); _commandSystemMock.VerifyAll(); }