public void ShouldNotFindAnyDockerFiles()
        {
            var mockFileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { $"C:{Slash}dev{Slash}solutionfolder{Slash}src{Slash}srcprojectfolder{Slash}srcproject.txt", new MockFileData("") },
                { $"C:{Slash}dev{Slash}solutionfolder{Slash}tests{Slash}testprojectfolder{Slash}testproject.cs", new MockFileData("") },
                { $"C:{Slash}dev{Slash}solutionfolder{Slash}other{Slash}random{Slash}folder{Slash}otherproj.vb", new MockFileData("") }
            });

            var fileFinder = new ProjectFileFinder(mockFileSystem);

            var results = fileFinder.Search($"C:{Slash}dev{Slash}solutionfolder{Slash}").ToList();

            Assert.That(results.Count, Is.EqualTo(0));
        }
Example #2
0
        public void ShouldFindAllProjectFilesInSpecifiedDirectory()
        {
            var mockFileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { $"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}src{OS.Slash}srcprojectfolder{OS.Slash}srcproject.csproj", new MockFileData("") },
                { $"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}tests{OS.Slash}testprojectfolder{OS.Slash}testproject.csproj", new MockFileData("") },
                { $"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}other{OS.Slash}random{OS.Slash}folder{OS.Slash}otherproj.csproj", new MockFileData("") }
            });

            var fileFinder = new ProjectFileFinder(mockFileSystem);

            var results = fileFinder.Search($"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}").ToList();

            Assert.That(results.Count, Is.EqualTo(3));
            Assert.That(results.First().Name, Is.EqualTo("srcproject.csproj"));
            Assert.That(results[1].Name, Is.EqualTo("testproject.csproj"));
            Assert.That(results[2].Name, Is.EqualTo("otherproj.csproj"));
        }
Example #3
0
        public void ShouldFindAllProjectFilesTypes()
        {
            var mockFileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { $"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}src{OS.Slash}srcprojectfolder{OS.Slash}srcproject.csproj", new MockFileData("") },
                { $"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}tests{OS.Slash}testprojectfolder{OS.Slash}testproject.vbproj", new MockFileData("") },
                { $"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}other{OS.Slash}random{OS.Slash}folder{OS.Slash}otherproj.fsproj", new MockFileData("") },
                { $"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}unknown{OS.Slash}unknownproj.ukproj", new MockFileData("") }
            });

            var fileFinder = new ProjectFileFinder(mockFileSystem);

            var results = fileFinder.Search($"C:{OS.Slash}dev{OS.Slash}solutionfolder{OS.Slash}").ToList();

            Assert.That(results.Count, Is.EqualTo(4));
            Assert.That(results.First().Name, Is.EqualTo("srcproject.csproj"));
            Assert.That(results[1].Name, Is.EqualTo("testproject.vbproj"));
            Assert.That(results[2].Name, Is.EqualTo("otherproj.fsproj"));
            //TODO: at some point, filter out anything other that the above
            Assert.That(results[3].Name, Is.EqualTo("unknownproj.ukproj"));
        }
        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));
        }