Ejemplo n.º 1
0
        public async Task WhenDimensionsAreGiven_ThenThePropertyIsOnlySetInTheMatchingConfigurations()
        {
            var project = UnconfiguredProjectFactory.Create(fullPath: @"C:\alpha\beta\MyProject.csproj");

            var projectConfigurations = GetConfigurations();

            var affectedConfigs = new List <string>();

            var queryCacheProvider = IPropertyPageQueryCacheProviderFactory.Create(
                IPropertyPageQueryCacheFactory.Create(
                    projectConfigurations,
                    bindToRule: (config, schemaName) => IRuleFactory.Create(
                        name: "MyPage",
                        properties: new[]
            {
                IPropertyFactory.Create("MyProperty", setValue: o => affectedConfigs.Add(config.Name))
            })));
            var targetDimensions = new List <(string dimension, string value)>
            {
                ("Configuration", "Release"),
                ("Platform", "x86")
            };

            var coreActionExecutor = new ProjectSetUIPropertyValueActionCore(
                queryCacheProvider,
                pageName: "MyPage",
                propertyName: "MyProperty",
                targetDimensions,
                prop => prop.SetValueAsync("new value"));

            await coreActionExecutor.OnBeforeExecutingBatchAsync(new[] { project });

            await coreActionExecutor.ExecuteAsync(project);

            coreActionExecutor.OnAfterExecutingBatch();

            Assert.Single(affectedConfigs);
            Assert.Contains("Release|x86", affectedConfigs);
        }
Ejemplo n.º 2
0
        public async Task WhenARuleContainsMultipleProperties_ThenOnlyTheSpecifiedPropertyIsSet()
        {
            var project = UnconfiguredProjectFactory.Create(fullPath: @"C:\alpha\beta\MyProject.csproj");
            var projectConfigurations = GetConfigurations();

            var unrelatedPropertySet = false;

            var queryCacheProvider = IPropertyPageQueryCacheProviderFactory.Create(
                IPropertyPageQueryCacheFactory.Create(
                    projectConfigurations,
                    bindToRule: (config, schemaName) => IRuleFactory.Create(
                        name: "MyPage",
                        properties: new[]
            {
                IPropertyFactory.Create("MyProperty", setValue: o => { }),
                IPropertyFactory.Create("NotTheCorrectProperty", setValue: o => unrelatedPropertySet = true)
            })));
            var targetDimensions = new List <(string dimension, string value)>
            {
                ("Configuration", "Release"),
                ("Platform", "x86")
            };

            var coreActionExecutor = new ProjectSetUIPropertyValueActionCore(
                queryCacheProvider,
                pageName: "MyPage",
                propertyName: "MyProperty",
                targetDimensions,
                prop => prop.SetValueAsync("new value"));

            await coreActionExecutor.OnBeforeExecutingBatchAsync(new[] { project });

            await coreActionExecutor.ExecuteAsync(project);

            coreActionExecutor.OnAfterExecutingBatch();

            Assert.False(unrelatedPropertySet);
        }
Ejemplo n.º 3
0
        public async Task WhenNoDimensionsAreGiven_ThenThePropertyIsSetInAllConfigurations()
        {
            var project = UnconfiguredProjectFactory.Create(fullPath: @"C:\alpha\beta\MyProject.csproj");

            var projectConfigurations = GetConfigurations();

            var affectedConfigs = new List <string>();

            var queryCacheProvider = IPropertyPageQueryCacheProviderFactory.Create(
                IPropertyPageQueryCacheFactory.Create(
                    projectConfigurations,
                    bindToRule: (config, schemaName) => IRuleFactory.Create(
                        name: "MyPage",
                        properties: new[]
            {
                IPropertyFactory.Create("MyProperty", setValue: o => affectedConfigs.Add(config.Name))
            })));
            var emptyTargetDimensions = Enumerable.Empty <(string dimension, string value)>();

            var coreActionExecutor = new ProjectSetUIPropertyValueActionCore(
                queryCacheProvider,
                pageName: "MyPage",
                propertyName: "MyProperty",
                emptyTargetDimensions,
                prop => prop.SetValueAsync("new value"));

            await coreActionExecutor.OnBeforeExecutingBatchAsync(new[] { project });

            await coreActionExecutor.ExecuteAsync(project);

            coreActionExecutor.OnAfterExecutingBatch();

            Assert.Equal(expected: 4, actual: affectedConfigs.Count);
            foreach (var configuration in projectConfigurations)
            {
                Assert.Contains(configuration.Name, affectedConfigs);
            }
        }
Ejemplo n.º 4
0
        public async Task WhenDimensionsAreGiven_ThenThePropertyIsOnlySetInTheMatchingConfigurations()
        {
            var project = UnconfiguredProjectFactory.Create(
                fullPath: @"C:\alpha\beta\MyProject.csproj",
                configuredProject: ConfiguredProjectFactory.Create(
                    services: ConfiguredProjectServicesFactory.Create(
                        IPropertyPagesCatalogProviderFactory.Create(new()
            {
                {
                    "Project",
                    IPropertyPagesCatalogFactory.Create(new Dictionary <string, ProjectSystem.Properties.IRule>()
                    {
                        { "MyPage", IRuleFactory.Create(new Rule
                            {
                                Name       = "MyPage",
                                Properties = new()
                                {
                                    new TestProperty
                                    {
                                        Name       = "MyProperty",
                                        DataSource = new() { HasConfigurationCondition = true }
                                    }
                                }
                            }) }
                    })
                }
            }))));
            var projectConfigurations = GetConfigurations();

            var affectedConfigs = new List <string>();

            var queryCacheProvider = IPropertyPageQueryCacheProviderFactory.Create(
                IPropertyPageQueryCacheFactory.Create(
                    projectConfigurations,
                    bindToRule: (config, schemaName) => IRuleFactory.Create(
                        name: "MyPage",
                        properties: new[]
            {
                IPropertyFactory.Create(
                    "MyProperty",
                    dataSource: IDataSourceFactory.Create(hasConfigurationCondition: true),
                    setValue: o => affectedConfigs.Add(config.Name))
            })));
            var targetDimensions = new List <(string dimension, string value)>
            {
                ("Configuration", "Release"),
                ("Platform", "x86")
            };

            var coreActionExecutor = new ProjectSetUIPropertyValueActionCore(
                queryCacheProvider,
                pageName: "MyPage",
                propertyName: "MyProperty",
                targetDimensions,
                prop => prop.SetValueAsync("new value"));

            await coreActionExecutor.OnBeforeExecutingBatchAsync(new[] { project });

            await coreActionExecutor.ExecuteAsync(project);

            coreActionExecutor.OnAfterExecutingBatch();

            Assert.Single(affectedConfigs);
            Assert.Contains("Release|x86", affectedConfigs);
        }
Ejemplo n.º 5
0
        public async Task WhenNoDimensionsAreGiven_ThenThePropertyIsSetInAllConfigurations()
        {
            var project = UnconfiguredProjectFactory.Create(
                fullPath: @"C:\alpha\beta\MyProject.csproj",
                configuredProject: ConfiguredProjectFactory.Create(
                    services: ConfiguredProjectServicesFactory.Create(
                        IPropertyPagesCatalogProviderFactory.Create(new()
            {
                {
                    "Project",
                    IPropertyPagesCatalogFactory.Create(new Dictionary <string, ProjectSystem.Properties.IRule>()
                    {
                        { "MyPage", IRuleFactory.Create(new Rule
                            {
                                Name       = "MyPage",
                                Properties = new()
                                {
                                    new TestProperty
                                    {
                                        Name       = "MyProperty",
                                        DataSource = new() { HasConfigurationCondition = true }
                                    }
                                }
                            }) }
                    })
                }
            }))));

            var projectConfigurations = GetConfigurations();

            var affectedConfigs = new List <string>();

            var queryCacheProvider = IPropertyPageQueryCacheProviderFactory.Create(
                IPropertyPageQueryCacheFactory.Create(
                    projectConfigurations,
                    bindToRule: (config, schemaName) => IRuleFactory.Create(
                        name: "MyPage",
                        properties: new[]
            {
                IPropertyFactory.Create(
                    "MyProperty",
                    dataSource: IDataSourceFactory.Create(hasConfigurationCondition: true),
                    setValue: o => affectedConfigs.Add(config.Name))
            })));
            var emptyTargetDimensions = Enumerable.Empty <(string dimension, string value)>();

            var coreActionExecutor = new ProjectSetUIPropertyValueActionCore(
                queryCacheProvider,
                pageName: "MyPage",
                propertyName: "MyProperty",
                emptyTargetDimensions,
                prop => prop.SetValueAsync("new value"));

            await coreActionExecutor.OnBeforeExecutingBatchAsync(new[] { project });

            await coreActionExecutor.ExecuteAsync(project);

            coreActionExecutor.OnAfterExecutingBatch();

            Assert.Equal(expected: 4, actual: affectedConfigs.Count);
            foreach (var configuration in projectConfigurations)
            {
                Assert.Contains(configuration.Name, affectedConfigs);
            }
        }