public async void ConfigurationProjectConfigurationDimensionProvider_OnDimensionValueChanged_Add() { 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.After nothing should be changed ProjectConfigurationDimensionValueChangedEventArgs args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Add, ChangeEventStage.After, ConfigurationGeneral.ConfigurationProperty, "CustomConfig"); 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 added args = new ProjectConfigurationDimensionValueChangedEventArgs( unconfiguredProject, ConfigurationDimensionChange.Add, ChangeEventStage.Before, ConfigurationGeneral.ConfigurationProperty, "CustomConfig"); await provider.OnDimensionValueChangedAsync(args); property = BuildUtilities.GetProperty(projectFile.Project, Configurations); Assert.NotNull(property); Assert.Equal("Debug;Release;CustomConfiguration;CustomConfig", property.Value); } }
public async void ConfigurationProjectConfigurationDimensionProvider_OnDimensionValueChanged_Remove_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.Delete, ChangeEventStage.Before, ConfigurationGeneral.ConfigurationProperty, "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); } }