public static ProjectProperties Create(UnconfiguredProject unconfiguredProject, params PropertyPageData[] data) { var catalog = CreateCatalog(CreateCatalogLookup(data)); IPropertyPagesCatalogProvider propertyPagesCatalogProvider = CreateCatalogProvider( new Dictionary <string, IPropertyPagesCatalog> { { "Project", catalog } }, catalog ); IAdditionalRuleDefinitionsService ruleService = Mock.Of <IAdditionalRuleDefinitionsService>(); IConfiguredProjectServices configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o => o.PropertyPagesCatalog == propertyPagesCatalogProvider && o.AdditionalRuleDefinitions == ruleService); var cfg = new StandardProjectConfiguration("Debug|" + "AnyCPU", Empty.PropertiesMap.SetItem("Configuration", "Debug").SetItem("Platform", "AnyCPU")); ConfiguredProject configuredProject = Mock.Of <ConfiguredProject>(o => o.UnconfiguredProject == unconfiguredProject && o.Services == configuredProjectServices && o.ProjectConfiguration == cfg); return(new ProjectProperties(configuredProject)); }
public TestConfiguredProject(TestUnconfiguredProject unconfiguredProject, TestPropertyData[] data) { UnconfiguredProject = unconfiguredProject; Services = new TestConfiguredProjectServices(this, data); ProjectConfiguration = new StandardProjectConfiguration( "Debug|AnyCPU", ImmutableDictionary <string, string> .Empty.Add("Configuration", "Debug").Add("Platform", "AnyCPU")); }
public async Task VerifyExpectedBehaviors(string projectPath, bool crossTargeting, bool implicitlyTriggeredBuild, string[] startupProjects, bool globalOptionEnabled, bool expectTargetFrameworkSet) { var projectService = IProjectServiceFactory.Create(); var unconfiguredProject = UnconfiguredProjectFactory.Create(fullPath: projectPath); ConfiguredProject?configuredProject; if (crossTargeting) { var dimensions = Empty.PropertiesMap .Add("Configuration", "Debug") .Add("Platform", "AnyCPU") .Add("TargetFramework", "netcoreapp1.0"); var projectConfiguration = new StandardProjectConfiguration("Debug|AnyCPU|netcoreapp1.0", dimensions); configuredProject = ConfiguredProjectFactory.Create(projectConfiguration: projectConfiguration, unconfiguredProject: unconfiguredProject); } else { var dimensions = Empty.PropertiesMap .Add("Configuration", "Debug") .Add("Platform", "AnyCPU"); var projectConfiguration = new StandardProjectConfiguration("Debug|AnyCPU", dimensions); configuredProject = ConfiguredProjectFactory.Create(projectConfiguration: projectConfiguration, unconfiguredProject: unconfiguredProject); } var activeDebugFrameworkServices = IActiveDebugFrameworkServicesFactory.ImplementGetActiveDebuggingFrameworkPropertyAsync("myFramework1.0"); var implicitlyTriggeredBuildState = IImplicityTriggeredBuildStateFactory.Create(implicitlyTriggeredBuild, startupProjects); var projectSystemOptions = IProjectSystemOptionsFactory.ImplementGetPreferSingleTargetBuildsForStartupProjectsAsync(ct => globalOptionEnabled); var provider = new StartupProjectSingleTargetGlobalBuildPropertyProvider( projectService, configuredProject, activeDebugFrameworkServices, implicitlyTriggeredBuildState, projectSystemOptions); var globalProperties = await provider.GetGlobalPropertiesAsync(CancellationToken.None); if (expectTargetFrameworkSet) { Assert.Equal(expected: 1, actual: globalProperties.Count); Assert.Equal(expected: "myFramework1.0", actual: globalProperties[ConfigurationGeneral.TargetFrameworkProperty]); } else { Assert.Empty(globalProperties); } }
public async Task VerifyNoTargetFrameworkOverrideForRegularBuild() { var dimensions = Empty.PropertiesMap .Add("Configuration", "Debug") .Add("Platform", "AnyCPU"); var projectConfiguration = new StandardProjectConfiguration("Debug|AnyCPU", dimensions); var configuredProject = ConfiguredProjectFactory.Create(projectConfiguration: projectConfiguration); var projectService = IProjectServiceFactory.Create(); var provider = new TargetFrameworkGlobalBuildPropertyProvider(projectService, configuredProject); var properties = await provider.GetGlobalPropertiesAsync(CancellationToken.None); Assert.Equal(0, properties.Count); }
public TestConfiguredProject(TestUnconfiguredProject unconfiguredProject, TestPropertyData[] data) { UnconfiguredProject = unconfiguredProject; var services = new Mock <ConfiguredProjectServices>(MockBehavior.Strict); services.Setup(s => s.AdditionalRuleDefinitions).Returns(new TestAdditionalRuleDefinitionsService()); services.Setup(s => s.PropertyPagesCatalog).Returns(new TestPropertyPagesCatalogProvider(new TestPropertyPagesCatalog(data))); services.Setup(s => s.ProjectService).Returns(UnconfiguredProject.ProjectService); Services = services.Object; ProjectConfiguration = new StandardProjectConfiguration( "Debug|AnyCPU", ImmutableDictionary <string, string> .Empty.Add("Configuration", "Debug").Add("Platform", "AnyCPU")); }
public async Task VerifyTargetFrameworkOverrideForCrossTargetingBuild() { var dimensions = Empty.PropertiesMap .Add("Configuration", "Debug") .Add("Platform", "AnyCPU") .Add("TargetFramework", "netcoreapp1.0"); var projectConfiguration = new StandardProjectConfiguration("Debug|AnyCPU|netcoreapp1.0", dimensions); var configuredProject = ConfiguredProjectFactory.Create(projectConfiguration: projectConfiguration); var projectService = IProjectServiceFactory.Create(); var provider = new TargetFrameworkGlobalBuildPropertyProvider(projectService, configuredProject); var properties = await provider.GetGlobalPropertiesAsync(CancellationToken.None); Assert.Single(properties); Assert.Equal("TargetFramework", properties.Keys.First()); Assert.Equal(string.Empty, properties.Values.First()); }