Exemple #1
0
        private Updater CreateVersionUpdater(IFileSystem mockFileSystem)
        {
            var projectFileFileFinder       = new ProjectFileFinder(mockFileSystem);
            var dockerFileFileFinder        = new DockerFileFinder(mockFileSystem);
            var environmentFileFileFinder   = new EnvironmentFileFinder(mockFileSystem);
            var dockerComposeFileFileFinder = new DockerComposeFileFinder(mockFileSystem);

            return(new Updater(_dotNetVersionUpdater, new PhysicalConsole(), projectFileFileFinder,
                               dockerFileFileFinder, environmentFileFileFinder, dockerComposeFileFileFinder, mockFileSystem));
        }
 public void BeforeEach()
 {
     options    = new SlnGenerationOptions(WorkingDirectory);
     finder     = MockRepository.GenerateStrictMock <ProjectFileFinder>();
     reader     = MockRepository.GenerateStrictMock <CsProjReader>();
     repository = new CsProjRepository
     {
         Finder = finder,
         Reader = reader
     };
 }
        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));
        }
Exemple #4
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"));
        }
Exemple #5
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));
        }
 public void BeforeEach()
 {
     finder = new ProjectFileFinder();
 }