public void ShouldFindAllDockerFilesInSpecifiedDirectory() { var mockFileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { $"C:{Slash}dev{Slash}solutionfolder{Slash}src{Slash}srcprojectfolder{Slash}DockerFile", new MockFileData("") }, { $"C:{Slash}dev{Slash}solutionfolder{Slash}tests{Slash}testprojectfolder{Slash}dockerfile", new MockFileData("") }, { $"C:{Slash}dev{Slash}solutionfolder{Slash}other{Slash}random{Slash}folder{Slash}dockerFile", new MockFileData("") }, { $"C:{Slash}dev{Slash}solutionfolder{Slash}other{Slash}random{Slash}goals{Slash}DOCKERFILE", new MockFileData("") }, { $"C:{Slash}dev{Slash}solutionfolder{Slash}other{Slash}random{Slash}test{Slash}DockerFile.test", new MockFileData("") } }); var fileFinder = new DockerFileFinder(mockFileSystem); var results = fileFinder.Search($"C:{Slash}dev{Slash}solutionfolder{Slash}").ToList(); Assert.That(results.Count, Is.EqualTo(5)); Assert.That(results.First().Name, Is.EqualTo("DockerFile")); Assert.That(results[1].Name, Is.EqualTo("dockerfile")); Assert.That(results[2].Name, Is.EqualTo("dockerFile")); Assert.That(results[3].Name, Is.EqualTo("DOCKERFILE")); Assert.That(results[4].Name, Is.EqualTo("DockerFile.test")); }
public async Task <int> OnExecute(CommandLineApplication app, IConsole console) { if (string.IsNullOrWhiteSpace(Path)) { Path = Directory.GetCurrentDirectory(); } if (!Directory.Exists(Path)) { console.WriteLine("Supplied Path does not exist. Aborting"); return(await Task.FromResult(-1)); } console.WriteLine($"Starting updating of {Path}"); var projectFileFileFinder = new ProjectFileFinder(_fileSystem); var dockerFileFinder = new DockerFileFinder(_fileSystem); var environmentFileFinder = new EnvironmentFileFinder(_fileSystem); var fileUpdater = new FileUpdater(console); var dockerFiles = dockerFileFinder.Search(Path); var projectFiles = projectFileFileFinder.Search(Path); var envFiles = environmentFileFinder.Search(Path); //TODO: inject the version updater based on the version the user wants var dotNetVersionUpdater = new Version2Point1Updater(); fileUpdater.UpdateProjectFiles(projectFiles, dotNetVersionUpdater); fileUpdater.UpdateDockerFiles(dockerFiles, dotNetVersionUpdater); fileUpdater.UpdateEnvironmentFiles(envFiles, dotNetVersionUpdater); if (Test) { var dotnet = new DotNet(); dotnet.Test(); } return(await Task.FromResult(0)); }