public async Task GetDefaultValuesForDimensionsAsync_NoPropertyValue() { using (var projectFile = new MsBuildProjectFile()) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new ConfigurationProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); var values = await provider.GetDefaultValuesForDimensionsAsync(unconfiguredProject); Assert.Empty(values); } }
public async Task GetProjectConfigurationDimensionsAsync_TFM() { using (var projectFile = new MsBuildProjectFile(ProjectXmlTFM)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new TargetFrameworkProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); var values = await provider.GetProjectConfigurationDimensionsAsync(unconfiguredProject); Assert.Empty(values); } }
public async Task GetProjectConfigurationDimensionsAsync_TFM() { var project = ProjectRootElementFactory.Create(ProjectXmlTFM); { var projectXmlAccessor = IProjectXmlAccessorFactory.Create(project); var provider = new TargetFrameworkProjectConfigurationDimensionProvider(projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(); var values = await provider.GetProjectConfigurationDimensionsAsync(unconfiguredProject); Assert.Empty(values); } }
public async Task PlatformProjectConfigurationDimensionProvider_GetDefaultValuesForDimensionsAsync() { var project = ProjectRootElementFactory.Create(projectXml); var projectXmlAccessor = IProjectXmlAccessorFactory.Create(project); var provider = new PlatformProjectConfigurationDimensionProvider(projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(); var values = await provider.GetDefaultValuesForDimensionsAsync(unconfiguredProject); Assert.Single(values); var value = values.First(); Assert.Equal(ConfigurationGeneral.PlatformProperty, value.Key); Assert.Equal("AnyCPU", value.Value); }
public async Task GetDefaultValuesForDimensionsAsync_TFMs(string projectXml) { var project = ProjectRootElementFactory.Create(projectXml); var projectXmlAccessor = IProjectXmlAccessorFactory.Create(project); var provider = new TargetFrameworkProjectConfigurationDimensionProvider(projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(); var values = await provider.GetDefaultValuesForDimensionsAsync(unconfiguredProject); Assert.Single(values); var value = values.First(); Assert.Equal(ConfigurationGeneral.TargetFrameworkProperty, value.Key); Assert.Equal("netcoreapp1.0", value.Value); }
public async Task TargetFrameworkProjectConfigurationDimensionProvider_GetDefaultValuesForDimensionsAsync_TFMs(string projectXml) { using (var projectFile = new MsBuildProjectFile(projectXml)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new TargetFrameworkProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); var values = await provider.GetDefaultValuesForDimensionsAsync(unconfiguredProject); Assert.Equal(1, values.Count()); var value = values.First(); Assert.Equal(ConfigurationGeneral.TargetFrameworkProperty, value.Key); Assert.Equal("netcoreapp1.0", value.Value); } }
public async void ConfigurationProjectConfigurationDimensionProvider_GetDefaultValuesForDimensionsAsync() { using (var projectFile = new MsBuildProjectFile(projectXml)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new ConfigurationProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); var values = await provider.GetDefaultValuesForDimensionsAsync(unconfiguredProject); Assert.Equal(1, values.Count()); var value = values.First(); Assert.Equal(ConfigurationGeneral.ConfigurationProperty, value.Key); Assert.Equal("Debug", value.Value); } }
public async Task GetProjectConfigurationDimensionsAsync_TFMs(string projectXml) { var project = ProjectRootElementFactory.Create(projectXml); var projectXmlAccessor = IProjectXmlAccessorFactory.Create(project); var provider = new TargetFrameworkProjectConfigurationDimensionProvider(projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(); var values = await provider.GetProjectConfigurationDimensionsAsync(unconfiguredProject); Assert.Single(values); var value = values.First(); Assert.Equal(ConfigurationGeneral.TargetFrameworkProperty, value.Key); string[] dimensionValues = value.Value.ToArray(); AssertEx.CollectionLength(dimensionValues, 2); Assert.Equal("netcoreapp1.0", dimensionValues[0]); Assert.Equal("net45", dimensionValues[1]); }
public async void TargetFrameworkProjectConfigurationDimensionProvider_GetProjectConfigurationDimensionsAsync_TFMs(string projectXml) { using (var projectFile = new MsBuildProjectFile(projectXml)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new TargetFrameworkProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); var values = await provider.GetProjectConfigurationDimensionsAsync(unconfiguredProject); Assert.Equal(1, values.Count()); var value = values.First(); Assert.Equal(ConfigurationGeneral.TargetFrameworkProperty, value.Key); string[] dimensionValues = value.Value.ToArray(); Assert.Equal(2, dimensionValues.Length); Assert.Equal("netcoreapp1.0", dimensionValues[0]); Assert.Equal("net45", dimensionValues[1]); } }
public async Task PlatformProjectConfigurationDimensionProvider_GetProjectConfigurationDimensionsAsync() { var project = ProjectRootElementFactory.Create(projectXml); var projectXmlAccessor = IProjectXmlAccessorFactory.Create(project); var provider = new PlatformProjectConfigurationDimensionProvider(projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(); var values = await provider.GetProjectConfigurationDimensionsAsync(unconfiguredProject); Assert.Single(values); var value = values.First(); Assert.Equal(ConfigurationGeneral.PlatformProperty, value.Key); string[] dimensionValues = value.Value.ToArray(); Assert.Equal(3, dimensionValues.Length); Assert.Equal("AnyCPU", dimensionValues[0]); Assert.Equal("x64", dimensionValues[1]); Assert.Equal("x86", dimensionValues[2]); }
public async void ConfigurationProjectConfigurationDimensionProvider_GetProjectConfigurationDimensionsAsync() { using (var projectFile = new MsBuildProjectFile(projectXml)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new ConfigurationProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); var values = await provider.GetProjectConfigurationDimensionsAsync(unconfiguredProject); Assert.Equal(1, values.Count()); var value = values.First(); Assert.Equal(ConfigurationGeneral.ConfigurationProperty, value.Key); string[] dimensionValues = value.Value.ToArray(); Assert.Equal(3, dimensionValues.Length); Assert.Equal("Debug", dimensionValues[0]); Assert.Equal("Release", dimensionValues[1]); Assert.Equal("CustomConfiguration", dimensionValues[2]); } }
public async Task OnDimensionValueChanged_Remove_MissingValue() { var project = ProjectRootElementFactory.Create(projectXml); var projectXmlAccessor = IProjectXmlAccessorFactory.Create(project); var provider = new ConfigurationProjectConfigurationDimensionProvider(projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(); var args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Delete, ChangeEventStage.Before, ConfigurationGeneral.ConfigurationProperty, "NonExistantConfiguration"); await Assert.ThrowsAsync <ArgumentException>(() => provider.OnDimensionValueChangedAsync(args)); var property = BuildUtilities.GetProperty(project, Configurations); Assert.NotNull(property); Assert.Equal("Debug;Release;CustomConfiguration", property.Value); }
public async Task OnDimensionValueChanged(ConfigurationDimensionChange change, ChangeEventStage stage) { // No changes should happen for TFM so verify that the property is the same before and after var project = ProjectRootElementFactory.Create(ProjectXmlTFMs); var projectXmlAccessor = IProjectXmlAccessorFactory.Create(project); var provider = new TargetFrameworkProjectConfigurationDimensionProvider(projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(); var property = BuildUtilities.GetProperty(project, ConfigurationGeneral.TargetFrameworksProperty); string expectedTFMs = property.Value; var args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, change, stage, ConfigurationGeneral.TargetFrameworkProperty, "NewTFM"); await provider.OnDimensionValueChangedAsync(args); Assert.NotNull(property); Assert.Equal(expectedTFMs, property.Value); }
public async void ConfigurationProjectConfigurationDimensionProvider_OnDimensionValueChanged_Rename_MissingValue() { using (var projectFile = new MsBuildProjectFile(projectXml)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new ConfigurationProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); ProjectConfigurationDimensionValueChangedEventArgs args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Rename, ChangeEventStage.After, ConfigurationGeneral.ConfigurationProperty, "RenamedConfiguration", "NonExistantConfiguration"); await Assert.ThrowsAsync <ArgumentException>(() => provider.OnDimensionValueChangedAsync(args)); var property = BuildUtilities.GetProperty(projectFile.Project, Configurations); Assert.NotNull(property); Assert.Equal("Debug;Release;CustomConfiguration", property.Value); } }
public async Task PlatformProjectConfigurationDimensionProvider_OnDimensionValueChanged_Rename() { using (var projectFile = new MsBuildProjectFile(projectXml)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new PlatformProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); // Nothing should happen on platform rename as it's unsupported ProjectConfigurationDimensionValueChangedEventArgs args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Rename, ChangeEventStage.Before, ConfigurationGeneral.PlatformProperty, "RenamedPlatform", "x86"); await provider.OnDimensionValueChangedAsync(args); var property = BuildUtilities.GetProperty(projectFile.Project, Platforms); Assert.NotNull(property); Assert.Equal("AnyCPU;x64;x86", property.Value); // On ChangeEventStage.Before the property should be renamed args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Rename, ChangeEventStage.After, ConfigurationGeneral.PlatformProperty, "RenamedPlatform", "x86"); await provider.OnDimensionValueChangedAsync(args); property = BuildUtilities.GetProperty(projectFile.Project, Platforms); Assert.NotNull(property); Assert.Equal("AnyCPU;x64;x86", property.Value); } }
public async void ConfigurationProjectConfigurationDimensionProvider_OnDimensionValueChanged_Rename() { using (var projectFile = new MsBuildProjectFile(projectXml)) { IProjectXmlAccessor _projectXmlAccessor = IProjectXmlAccessorFactory.Create(projectFile.Project); var provider = new ConfigurationProjectConfigurationDimensionProvider(_projectXmlAccessor); var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projectFile.Filename); // On ChangeEventStage.Before nothing should be changed ProjectConfigurationDimensionValueChangedEventArgs args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Rename, ChangeEventStage.Before, ConfigurationGeneral.ConfigurationProperty, "RenamedConfiguration", "CustomConfiguration"); await provider.OnDimensionValueChangedAsync(args); var property = BuildUtilities.GetProperty(projectFile.Project, Configurations); Assert.NotNull(property); Assert.Equal("Debug;Release;CustomConfiguration", property.Value); // On ChangeEventStage.Before the property should be renamed args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Rename, ChangeEventStage.After, ConfigurationGeneral.ConfigurationProperty, "RenamedConfiguration", "CustomConfiguration"); await provider.OnDimensionValueChangedAsync(args); property = BuildUtilities.GetProperty(projectFile.Project, Configurations); Assert.NotNull(property); Assert.Equal("Debug;Release;RenamedConfiguration", property.Value); } }
public async Task GetListedValues() { var projectXmlAccessor = IProjectXmlAccessorFactory.WithItems("SupportedTargetFramework", "DisplayName", new[] {