public void SetRepositoryAsCurrentDirectory() { var fileService = Substitute.For <IFileService>(); var consoleService = Substitute.For <IConsoleService>(); var repositoryService = Substitute.For <IRepositoryService>(); var handler = new RepositoryInitOrCreateCommandHandler(fileService, consoleService, repositoryService); var expectedRepoDirectory = "/dev/null"; fileService.GetCurrentDirectory().Returns(expectedRepoDirectory); fileService.DirectoryExists($"/dev/null{Path.DirectorySeparatorChar}.git").Returns(true); handler.Handle(new RepositoryInitOrCreateCommand(null)); fileService.Received(1).SetCurrentDirectory(expectedRepoDirectory); }
public void CreateRepositoryAtSpecifiedPath() { var fileService = Substitute.For <IFileService>(); var consoleService = Substitute.For <IConsoleService>(); var repositoryService = Substitute.For <IRepositoryService>(); var handler = new RepositoryInitOrCreateCommandHandler(fileService, consoleService, repositoryService); var expectedRepoDirectory = Path.GetFullPath(Path.Combine(Path.GetPathRoot("/"), "dev", "null", "test")); var parentFolder = Path.GetFullPath(Path.Combine(Path.GetPathRoot("/"), "dev", "null")); fileService.GetCurrentDirectory().Returns(parentFolder); fileService.DirectoryExists($"{expectedRepoDirectory}{Path.DirectorySeparatorChar}.git").Returns(true); handler.Handle(new RepositoryInitOrCreateCommand(expectedRepoDirectory)); fileService.Received(1).SetCurrentDirectory(expectedRepoDirectory); }