public void WriteProjectInfo_ContentFileList_AutoGenFilesIgnored() { // The content file list should not include items with <AutoGen>true</AutoGen> metadata // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "agC.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Files we don't expect to be included AddFileToProject(projectRoot, TargetProperties.ItemType_Content, null, "TRUE"); // only AutoGen, set to true AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "false", "truE"); // exclude=false, autogen=true AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "true", "false"); // exclude=true, autogen=false AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, null, "false"); // autogen=false, but wrong item type AddFileToProject(projectRoot, TargetProperties.ItemType_Compile, null, null); // wrong item type // Files we expect to be included string content1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, null, null); // no metadata string autogenFalseAndIncluded = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "false", "FALSe"); // exclude=false, autogen=false // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileExists(projectInfo, AnalysisType.ContentFiles, content1, autogenFalseAndIncluded); }
public void WriteProjectInfo_ContentFileList_HasFiles() { // The content file list should be created with the expected files // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "content.X.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Files we expect to be included string file1 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "false"); string file2 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "FALSE"); string file3 = AddFileToProject(projectRoot, TargetProperties.ItemType_Content, null); // no metadata // Files we don't expect to be included AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "true"); AddFileToProject(projectRoot, TargetProperties.ItemType_Content, "TRUE"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileExists(projectInfo, AnalysisType.ContentFiles, file1, file2, file3); }
public void WriteProjectInfo_ContentFileList_NoFiles() { // The content file list should not be created if there are no files // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "content.proj.txt"); ProjectRootElement projectRoot = CreateInitializedProject(descriptor, new WellKnownProjectProperties(), rootOutputFolder); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(projectRoot, rootOutputFolder); // Assert AssertResultFileDoesNotExist(projectInfo, AnalysisType.ContentFiles); }
public void WriteProjectInfo_TestProject_WildcardMatch_Default_NoMatch() { // Check the default wildcard matching // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "foo.proj"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(descriptor, preImportProperties, rootOutputFolder); // Assert AssertIsProductProject(projectInfo); }
public void WriteProjectInfo_TestProject_WildcardMatch_UserSpecified_NoMatch() { // Check user-specified wildcard matching // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); EnsureAnalysisConfig(rootInputFolder, ".*foo.*"); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); // Use project name that will be recognised as a test by the default regex ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "TestafoXB.proj"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(descriptor, preImportProperties, rootOutputFolder); // Assert AssertIsProductProject(projectInfo); }
public void WriteProjectInfo_TestProject_ExplicitMarking_True() { // If the project is explicitly marked as a test then the other condition should be ignored // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); preImportProperties.SonarTestProject = "true"; EnsureAnalysisConfig(rootInputFolder, "pattern that won't match anything"); ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "test.proj"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(descriptor, preImportProperties, rootOutputFolder); // Assert AssertIsTestProject(projectInfo); }
public void WriteProjectInfo_TestProject_HasTestGuid_LowerCase() { // Checks the MSTest project type guid is recognised // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); EnsureAnalysisConfig(rootInputFolder, "pattern that won't match anything"); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); preImportProperties.ProjectTypeGuids = "X" + TargetConstants.MsTestProjectTypeGuid.ToLowerInvariant() + "Y"; ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "a.b"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(descriptor, preImportProperties, rootOutputFolder); // Assert AssertIsTestProject(projectInfo); }
public void WriteProjectInfo_TestProject_ExplicitMarking_False() { // If the project is explicitly marked as not a test then the other condition should be ignored // Arrange string rootInputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Inputs"); string rootOutputFolder = TestUtils.CreateTestSpecificFolder(this.TestContext, "Outputs"); EnsureAnalysisConfig(rootInputFolder, "*.*"); WellKnownProjectProperties preImportProperties = CreateDefaultAnalysisProperties(rootInputFolder, rootOutputFolder); preImportProperties.SonarTestProject = "false"; preImportProperties.ProjectTypeGuids = "X" + TargetConstants.MsTestProjectTypeGuid.ToUpperInvariant() + "Y"; ProjectDescriptor descriptor = BuildUtilities.CreateValidNamedProjectDescriptor(rootInputFolder, "foo.proj"); // Act ProjectInfo projectInfo = ExecuteWriteProjectInfo(descriptor, preImportProperties, rootOutputFolder); // Assert AssertIsProductProject(projectInfo); }