private IEnumerable <RuleSetDeclaration> SetSingleValidRuleSetDeclarationPerProject(string configurationName = "Configuration", bool useUniqueProjectRuleSets = false) { List <RuleSetDeclaration> declarations = new List <RuleSetDeclaration>(); foreach (ProjectMock project in this.projectHelper.FilteredProjects.OfType <ProjectMock>()) { var configuration = new ConfigurationMock(configurationName); project.ConfigurationManager.Configurations.Add(configuration); PropertyMock ruleSetProperty = configuration.Properties.RegisterKnownProperty(Constants.CodeAnalysisRuleSetPropertyKey); ruleSetProperty.Value = project.FilePath.ToUpperInvariant(); // Catch cases where file paths are compared without OrdinalIgnoreCase if (useUniqueProjectRuleSets) { ruleSetProperty.Value = Path.ChangeExtension(project.FilePath, configurationName + ".ruleSet"); } PropertyMock ruleSetDirectories = configuration.Properties.RegisterKnownProperty(Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); ruleSetDirectories.Value = ConflictsManager.CombineDirectories(new[] { this.TestContext.TestRunDirectory, "." }); RuleSetDeclaration declaration = new RuleSetDeclaration( project, ruleSetProperty, ruleSetProperty.Value.ToString().ToLowerInvariant(), // Catch cases where file paths are compared without OrdinalIgnoreCase configuration.ConfigurationName, ruleSetDirectories.Value.ToString().Split(';')); declarations.Add(declaration); this.ruleSetInfoProvider.RegisterProjectInfo(project, declaration); } return(declarations); }
private static PropertyMock CreateProperty(ProjectMock project, string configurationName, object propertyValue, string propertyName = Constants.CodeAnalysisRuleSetPropertyKey) { ConfigurationMock config = GetOrCreateConfiguration(project, configurationName); var prop = config.Properties.RegisterKnownProperty(propertyName); prop.Value = propertyValue; return(prop); }
private static ConfigurationMock GetOrCreateConfiguration(ProjectMock project, string configurationName) { ConfigurationMock config = project.ConfigurationManager.Configurations.SingleOrDefault(c => c.ConfigurationName == configurationName); if (config == null) { config = new ConfigurationMock(configurationName); project.ConfigurationManager.Configurations.Add(config); } return(config); }
private void SetValidProjectConfiguration(ProjectMock project, string configurationName = "Configuration") { var configuration = new ConfigurationMock(configurationName); project.ConfigurationManager.Configurations.Add(configuration); PropertyMock ruleSetProperty = configuration.Properties.RegisterKnownProperty(Constants.CodeAnalysisRuleSetPropertyKey); ruleSetProperty.Value = project.FilePath.ToUpperInvariant(); // Catch cases where file paths are compared without OrdinalIgnoreCase this.ruleSetInfoProvider.RegisterProjectInfo(project, new RuleSetDeclaration[] { new RuleSetDeclaration(project, ruleSetProperty, (string)ruleSetProperty.Value, configurationName) }); }
private static PropertyMock CreatePropertyForConfiguration(ProjectMock project, string configurationName, string propertyName, object propertyValue) { ConfigurationMock config = project.ConfigurationManager.Configurations.SingleOrDefault(c => c.ConfigurationName == configurationName); if (config == null) { config = new ConfigurationMock(configurationName); project.ConfigurationManager.Configurations.Add(config); } var prop = config.Properties.RegisterKnownProperty(propertyName); prop.Value = propertyValue; return(prop); }
private static ConfigurationMock GetOrCreateConfiguration(ProjectMock project, string configurationName) { ConfigurationMock config = project.ConfigurationManager.Configurations.SingleOrDefault(c => c.ConfigurationName == configurationName); if (config == null) { config = new ConfigurationMock(configurationName); project.ConfigurationManager.Configurations.Add(config); } return config; }
private IEnumerable<RuleSetDeclaration> SetSingleValidRuleSetDeclarationPerProject(string configurationName = "Configuration", bool useUniqueProjectRuleSets = false) { List<RuleSetDeclaration> declarations = new List<RuleSetDeclaration>(); foreach (ProjectMock project in this.projectHelper.FilteredProjects.OfType<ProjectMock>()) { var configuration = new ConfigurationMock(configurationName); project.ConfigurationManager.Configurations.Add(configuration); PropertyMock ruleSetProperty = configuration.Properties.RegisterKnownProperty(Constants.CodeAnalysisRuleSetPropertyKey); ruleSetProperty.Value = project.FilePath.ToUpperInvariant(); // Catch cases where file paths are compared without OrdinalIgnoreCase if (useUniqueProjectRuleSets) { ruleSetProperty.Value = Path.ChangeExtension(project.FilePath, configurationName + ".ruleSet"); } PropertyMock ruleSetDirectories = configuration.Properties.RegisterKnownProperty(Constants.CodeAnalysisRuleSetDirectoriesPropertyKey); ruleSetDirectories.Value = ConflictsManager.CombineDirectories(new[] { this.TestContext.TestRunDirectory, "." }); RuleSetDeclaration declaration = new RuleSetDeclaration( project, ruleSetProperty, ruleSetProperty.Value.ToString().ToLowerInvariant(), // Catch cases where file paths are compared without OrdinalIgnoreCase configuration.ConfigurationName, ruleSetDirectories.Value.ToString().Split(';')); declarations.Add(declaration); this.ruleSetInfoProvider.RegisterProjectInfo(project, declaration); } return declarations; }