public async Task GetProjectConfigurationDimensionsAsync_TFM()
        {
            var projectAccessor = IProjectAccessorFactory.Create(ProjectXmlTFM);
            var provider        = new TargetFrameworkProjectConfigurationDimensionProvider(projectAccessor);

            var project = UnconfiguredProjectFactory.Create();
            var values  = await provider.GetProjectConfigurationDimensionsAsync(project);

            Assert.Empty(values);
        }
        public async Task TargetFrameworkProjectConfigurationDimensionProvider_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.Equal(0, values.Count());
            }
        }
        public async Task GetDefaultValuesForDimensionsAsync_TFMs(string projectXml)
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);
            var provider        = new TargetFrameworkProjectConfigurationDimensionProvider(projectAccessor);

            var project = UnconfiguredProjectFactory.Create();
            var values  = await provider.GetDefaultValuesForDimensionsAsync(project);

            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 Task GetProjectConfigurationDimensionsAsync_TFMs(string projectXml)
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);
            var provider        = new TargetFrameworkProjectConfigurationDimensionProvider(projectAccessor);

            var project = UnconfiguredProjectFactory.Create();
            var values  = await provider.GetProjectConfigurationDimensionsAsync(project);

            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]);
        }
Esempio n. 6
0
        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]);
            }
        }
Esempio n. 7
0
        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);
        }