public void ProjectLoader() { // Arrange string testSourcePath = TestUtils.CreateTestSpecificFolder(this.TestContext); // Create sub-directories, some with project info XML files and some without TestUtils.EnsureTestSpecificFolder(this.TestContext, "EmptyDir1"); ProjectDescriptor validTestProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validTestProjectDir", ProjectFileName = "validTestProject.csproj", ProjectGuid = Guid.NewGuid(), IsTestProject = true }; validTestProject.AddCompileInputFile("TestFile1.cs", true); validTestProject.AddCompileInputFile("TestFile1.cs", true); validTestProject.AddContentFile("contentFile1.js", true); CreateFilesFromDescriptor(validTestProject, "testCompileListFile", "testContentList", "testFxCopReport", "testVisualStudioCodeCoverageReport"); TestUtils.EnsureTestSpecificFolder(this.TestContext, "EmptyDir2"); ProjectDescriptor validNonTestProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validNonTestProjectDir", ProjectFileName = "validNonTestproject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false }; validNonTestProject.AddContentFile("ASourceFile.vb", true); validNonTestProject.AddContentFile("AnotherSourceFile.vb", true); CreateFilesFromDescriptor(validNonTestProject, "list.txt", null, "fxcop.xml", "visualstudio-codecoverage.xml"); ProjectDescriptor validNonTestNoReportsProject = new ProjectDescriptor() { ParentDirectoryPath = testSourcePath, ProjectFolderName = "validNonTestNoReportsProjectDir", ProjectFileName = "validNonTestNoReportsProject.proj", ProjectGuid = Guid.NewGuid(), IsTestProject = false }; validNonTestNoReportsProject.AddContentFile("SomeFile.cs", true); CreateFilesFromDescriptor(validNonTestNoReportsProject, "SomeList.txt", null, null, null); // Act IEnumerable<ProjectInfo> projects = SonarRunner.Shim.ProjectLoader.LoadFrom(testSourcePath); // Assert Assert.AreEqual(3, projects.Count()); AssertProjectResultExists(validTestProject.ProjectName, projects); AssertProjectResultExists(validNonTestProject.ProjectName, projects); AssertProjectResultExists(validNonTestNoReportsProject.ProjectName, projects); }
private static void AddEmptyContentFile(ProjectDescriptor descriptor, string projectFolder) { string filePath = CreateEmptyFile(projectFolder, "txt"); descriptor.AddContentFile(filePath, true); }