Example #1
0
        public void ImportedFilePathIsFound()
        {
            var sample                = ProjectSampleGenerator.GetProjectWithImportSample("SampleProject.csproj");
            var projectFilePath       = sample.ProjectFile.GetFullPath(Repository.BasePath);
            var importedPropsFilePath = Path.Combine(Repository.BasePath, sample.ImportedPropsFile.Name);

            Repository
            .WriteFile(sample.ProjectFile)
            .WriteFile(sample.ImportedPropsFile);

            var projectFile = new SlnFileWithPath(projectFilePath, new SlnFile(FileType.Project, ProjectId.CreateNewId()));
            var imports     = ProjectImportsFinder.FindProjectImports(new[] { projectFile });

            imports.Values.Should().BeEquivalentTo(new ImportedFile(importedPropsFilePath, new[] { projectFile }.ToImmutableList()));
        }
Example #2
0
        public async Task Should_mark_project_as_changed_when_only_imported_file_changed()
        {
            var sample          = ProjectSampleGenerator.GetProjectWithImportSample("SampleProject.csproj");
            var projectFilePath = sample.ProjectFile.GetFullPath(Repository.BasePath);

            Repository
            .WriteFile(sample.ProjectFile)
            .WriteFile(sample.ImportedPropsFile)
            .Commit("Created sample project")
            .CreateBranch("foo")
            .CheckoutBranch("foo")
            .WriteFile(sample.ImportedPropsFile.Name, sample.ImportedPropsFile.Content + " ")
            .Commit("Updated imported file with a space");

            var cmd           = new FilterAffectedProjectFilesCmd(new TestOutputLogger(_outputHelper), new CancellationToken(), Repository.BasePath, "master");
            var solutionFiles = new Dictionary <string, SlnFile>()
            {
                [projectFilePath] = new SlnFile(FileType.Project, ProjectId.CreateNewId())
            };
            var filteredAffectedFiles = await cmd.Process(Task.FromResult(solutionFiles));

            filteredAffectedFiles.Should().HaveCount(1).And.Subject.Keys.Should().BeEquivalentTo(projectFilePath);
        }