public async Task OnDimensionValueChanged_Rename_UnknownValue()
        {
            string projectXml =
                "" "
                <Project>
                  <PropertyGroup>
                    <PROP>A;B;C</PROP>
                  </PropertyGroup>
                </Project>
                " "";

            var rootElement       = ProjectRootElementFactory.Create(projectXml.Replace("PROP", PropertyName));
            var projectAccessor   = IProjectAccessorFactory.Create(rootElement);
            var configuredProject = ConfiguredProjectFactory.Create();
            var provider          = CreateInstance(projectAccessor);
            var project           = UnconfiguredProjectFactory.Create(configuredProject: configuredProject);

            var args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Rename,
                ChangeEventStage.After,
                DimensionName,
                "Renamed",
                "Unknown");
            await Assert.ThrowsAsync <ArgumentException>(() => provider.OnDimensionValueChangedAsync(args));

            var property = BuildUtilities.GetProperty(rootElement, PropertyName);

            Assert.NotNull(property);
            Assert.Equal("A;B;C", property.Value);
        }
        public async Task GetListedValuesAsync_ReturnsSupportedTargetFrameworksItems()
        {
            string project =
                @"<Project>
    <ItemGroup>
        <SupportedTargetFramework Include="".NETCoreApp,Version=v1.0"" DisplayName="".NET Core 1.0"" />
        <SupportedTargetFramework Include="".NETCoreApp,Version=v1.1"" DisplayName="".NET Core 1.1"" />
        <SupportedTargetFramework Include="".NETCoreApp,Version=v2.0"" DisplayName="".NET Core 2.0"" />
    </ItemGroup>
</Project>";

            var projectAccessor = IProjectAccessorFactory.Create(project);

            var configuredProject = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            var values = await generator.GetListedValuesAsync();

            AssertEx.CollectionLength(values, 3);
            Assert.Equal(new List <string> {
                ".NETCoreApp,Version=v1.0", ".NETCoreApp,Version=v1.1", ".NETCoreApp,Version=v2.0"
            }, values.Select(v => v.Name));
            Assert.Equal(new List <string> {
                ".NET Core 1.0", ".NET Core 1.1", ".NET Core 2.0"
            }, values.Select(v => v.DisplayName));
        }
        public async Task PlatformProjectConfigurationDimensionProvider_OnDimensionValueChanged_Remove()
        {
            var rootElement     = ProjectRootElementFactory.Create(projectXml);
            var projectAccessor = IProjectAccessorFactory.Create(rootElement);
            var provider        = new PlatformProjectConfigurationDimensionProvider(projectAccessor);

            var project = UnconfiguredProjectFactory.Create();

            // On ChangeEventStage.After nothing should be changed
            var args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Delete,
                ChangeEventStage.After,
                ConfigurationGeneral.PlatformProperty,
                "x86");
            await provider.OnDimensionValueChangedAsync(args);

            var property = BuildUtilities.GetProperty(rootElement, Platforms);

            Assert.NotNull(property);
            Assert.Equal("AnyCPU;x64;x86", property.Value);

            // On ChangeEventStage.Before the property should be removed
            args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Delete,
                ChangeEventStage.Before,
                ConfigurationGeneral.PlatformProperty,
                "x86");
            await provider.OnDimensionValueChangedAsync(args);

            property = BuildUtilities.GetProperty(rootElement, Platforms);
            Assert.NotNull(property);
            Assert.Equal("AnyCPU;x64", property.Value);
        }
コード例 #4
0
        public void Constructor_NullConfiguredProject_ThrowsArgumentNull()
        {
            var projectAccessor = IProjectAccessorFactory.Create();

            Assert.Throws <ArgumentNullException>("configuredProject", () =>
            {
                new SupportedTargetFrameworksEnumProvider(projectAccessor, null);
            });
        }
コード例 #5
0
        public void Constructor_ValueAsCommonServices_SetsProjectAccessorToCommonServicesProjectAccessor()
        {
            var projectAccessor = IProjectAccessorFactory.Create();
            var commonServices  = IUnconfiguredProjectCommonServicesFactory.Create(projectAccessor: projectAccessor);

            var vsServices = CreateInstance(commonServices);

            Assert.Same(projectAccessor, vsServices.ProjectAccessor);
        }
コード例 #6
0
        internal AbstractMoveCommand CreateAbstractInstance(IPhysicalProjectTree projectTree = null, Shell.SVsServiceProvider serviceProvider = null, ConfiguredProject configuredProject = null, IProjectAccessor accessor = null)
        {
            projectTree       = projectTree ?? IPhysicalProjectTreeFactory.Create();
            serviceProvider   = serviceProvider ?? SVsServiceProviderFactory.Create();
            configuredProject = configuredProject ?? ConfiguredProjectFactory.Create();
            accessor          = accessor ?? IProjectAccessorFactory.Create();

            return(CreateInstance(projectTree, serviceProvider, configuredProject, accessor));
        }
コード例 #7
0
        public async Task GetProviderAsync_ReturnsNonNullGenerator()
        {
            var projectAccessor   = IProjectAccessorFactory.Create();
            var configuredProject = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            Assert.NotNull(generator);
        }
        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);
        }
コード例 #9
0
        public async Task TryCreateEnumValueAsync_ReturnsNull()
        {
            var projectAccessor   = IProjectAccessorFactory.Create();
            var configuredProject = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            Assert.Null(await generator.TryCreateEnumValueAsync("foo"));
        }
        public async Task GetDefaultValuesForDimensionsAsync_NoPropertyValue()
        {
            var projectAccessor = IProjectAccessorFactory.Create("<Project />");
            var provider        = new ConfigurationProjectConfigurationDimensionProvider(projectAccessor);
            var project         = UnconfiguredProjectFactory.Create();

            var values = await provider.GetDefaultValuesForDimensionsAsync(project);

            Assert.Empty(values);
        }
コード例 #11
0
        public async Task TryCreateEnumValueAsync_ThrowsNotImplemented()
        {
            var projectAccessor   = IProjectAccessorFactory.Create();
            var configuredProject = ConfiguredProjectFactory.Create();

            var provider  = new SupportedTargetFrameworksEnumProvider(projectAccessor, configuredProject);
            var generator = await provider.GetProviderAsync(null);

            Assert.Throws <NotImplementedException>(() =>
            {
                generator.TryCreateEnumValueAsync("foo");
            });
        }
        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 PlatformProjectConfigurationDimensionProvider_GetDefaultValuesForDimensionsAsync()
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);
            var provider        = new PlatformProjectConfigurationDimensionProvider(projectAccessor);

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

            Assert.Single(values);
            var value = values.First();

            Assert.Equal(ConfigurationGeneral.PlatformProperty, value.Key);
            Assert.Equal("AnyCPU", 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]);
        }
        public async Task OnDimensionValueChanged_Rename()
        {
            string projectXml =
                "" "
                <Project>
                  <PropertyGroup>
                    <PROP>A;B;C</PROP>
                  </PropertyGroup>
                </Project>
                " "";

            var rootElement       = ProjectRootElementFactory.Create(projectXml.Replace("PROP", PropertyName));
            var projectAccessor   = IProjectAccessorFactory.Create(rootElement);
            var configuredProject = ConfiguredProjectFactory.Create();
            var provider          = CreateInstance(projectAccessor);
            var project           = UnconfiguredProjectFactory.Create(configuredProject: configuredProject);

            // On ChangeEventStage.Before nothing should be changed
            var args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Rename,
                ChangeEventStage.Before,
                DimensionName,
                "Renamed",
                "B");
            await provider.OnDimensionValueChangedAsync(args);

            var property = BuildUtilities.GetProperty(rootElement, PropertyName);

            Assert.NotNull(property);
            Assert.Equal("A;B;C", property.Value);

            // On ChangeEventStage.Before the property should be renamed
            args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Rename,
                ChangeEventStage.After,
                DimensionName,
                "Renamed",
                "B");
            await provider.OnDimensionValueChangedAsync(args);

            property = BuildUtilities.GetProperty(rootElement, PropertyName);
            Assert.NotNull(property);
            Assert.Equal("A;Renamed;C", property.Value);
        }
        public async Task GetProjectConfigurationDimensionsAsync()
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);
            var provider        = new ConfigurationProjectConfigurationDimensionProvider(projectAccessor);
            var project         = UnconfiguredProjectFactory.Create();

            var values = await provider.GetProjectConfigurationDimensionsAsync(project);

            Assert.Single(values);
            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]);
        }
コード例 #17
0
        private DebugTokenReplacer CreateInstance()
        {
            var environmentHelper    = _envHelper.Object;
            var activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>();

            string projectFile = @"<Project>
                <PropertyGroup>
                    <msbuildProperty1>Property1</msbuildProperty1>
                    <msbuildProperty2>Property2</msbuildProperty2>
                    <msbuildProperty3>Property3</msbuildProperty3>
                    <msbuildProperty4>Property4</msbuildProperty4>
                    <msbuildProperty5>Property5</msbuildProperty5>
                    <msbuildProperty6>Property6</msbuildProperty6>
                </PropertyGroup>
                </Project>";

            return(new DebugTokenReplacer(environmentHelper, activeDebugFramework, IProjectAccessorFactory.Create(projectFile)));
        }
        public async Task PlatformProjectConfigurationDimensionProvider_GetProjectConfigurationDimensionsAsync()
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);
            var provider        = new PlatformProjectConfigurationDimensionProvider(projectAccessor);

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

            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]);
        }
コード例 #19
0
        private PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger          = IProjectLoggerFactory.Create();
            IFileSystem    fileSystem      = IFileSystemFactory.Create();
            var            hintService     = new Lazy <IProjectChangeHintSubmissionService>(() => IProjectChangeHintSubmissionServiceFactory.Create());
            var            projectAccessor = IProjectAccessorFactory.Create();

            return(new PackageRestoreDataSource(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       hintService,
                       projectAccessor,
                       logger));
        }
        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 rootElement     = ProjectRootElementFactory.Create(ProjectXmlTFMs);
            var projectAccessor = IProjectAccessorFactory.Create(rootElement);
            var provider        = new TargetFrameworkProjectConfigurationDimensionProvider(projectAccessor);

            var    project      = UnconfiguredProjectFactory.Create();
            var    property     = BuildUtilities.GetProperty(rootElement, ConfigurationGeneral.TargetFrameworksProperty);
            string expectedTFMs = property.Value;

            var args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                change,
                stage,
                ConfigurationGeneral.TargetFrameworkProperty,
                "NewTFM");
            await provider.OnDimensionValueChangedAsync(args);

            Assert.NotNull(property);
            Assert.Equal(expectedTFMs, property.Value);
        }
        public async Task OnDimensionValueChanged_Remove_MissingValue()
        {
            var rootElement     = ProjectRootElementFactory.Create(projectXml);
            var projectAccessor = IProjectAccessorFactory.Create(rootElement);

            var provider = new ConfigurationProjectConfigurationDimensionProvider(projectAccessor);

            var project = UnconfiguredProjectFactory.Create();

            var args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Delete,
                ChangeEventStage.Before,
                ConfigurationGeneral.ConfigurationProperty,
                "NonExistantConfiguration");
            await Assert.ThrowsAsync <ArgumentException>(() => provider.OnDimensionValueChangedAsync(args));

            var property = BuildUtilities.GetProperty(rootElement, Configurations);

            Assert.NotNull(property);
            Assert.Equal("Debug;Release;CustomConfiguration", property.Value);
        }
コード例 #22
0
        public static TestVisualBasicNamespaceImportsList CreateInstance(params string[] list)
        {
            var newList = new TestVisualBasicNamespaceImportsList(
                UnconfiguredProjectFactory.Create(),
                IProjectThreadingServiceFactory.Create(),
                IActiveConfiguredProjectSubscriptionServiceFactory.Create());

            newList.VSImports = new Lazy <VisualBasicVSImports>(() => new TestVisualBasicVSImports(
                                                                    Mock.Of <VSLangProj.VSProject>(),
                                                                    IProjectThreadingServiceFactory.Create(),
                                                                    IActiveConfiguredValueFactory.ImplementValue(() => ConfiguredProjectFactory.Create()),
                                                                    IProjectAccessorFactory.Create(),
                                                                    IUnconfiguredProjectVsServicesFactory.Create(),
                                                                    newList));

            newList.TestApply(list);

            newList.ImportsAdded.Clear();
            newList.ImportsRemoved.Clear();

            return(newList);
        }
        public async Task OnDimensionValueChanged_Rename()
        {
            var rootElement     = ProjectRootElementFactory.Create(projectXml);
            var projectAccessor = IProjectAccessorFactory.Create(rootElement);

            var provider = new ConfigurationProjectConfigurationDimensionProvider(projectAccessor);

            var project = UnconfiguredProjectFactory.Create();

            // On ChangeEventStage.Before nothing should be changed
            var args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Rename,
                ChangeEventStage.Before,
                ConfigurationGeneral.ConfigurationProperty,
                "RenamedConfiguration",
                "CustomConfiguration");
            await provider.OnDimensionValueChangedAsync(args);

            var property = BuildUtilities.GetProperty(rootElement, Configurations);

            Assert.NotNull(property);
            Assert.Equal("Debug;Release;CustomConfiguration", property.Value);

            // On ChangeEventStage.Before the property should be renamed
            args = new ProjectConfigurationDimensionValueChangedEventArgs(
                project,
                ConfigurationDimensionChange.Rename,
                ChangeEventStage.After,
                ConfigurationGeneral.ConfigurationProperty,
                "RenamedConfiguration",
                "CustomConfiguration");
            await provider.OnDimensionValueChangedAsync(args);

            property = BuildUtilities.GetProperty(rootElement, Configurations);
            Assert.NotNull(property);
            Assert.Equal("Debug;Release;RenamedConfiguration", property.Value);
        }
        private protected override BaseProjectConfigurationDimensionProvider CreateInstance(string projectXml)
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);

            return(CreateInstance(projectAccessor));
        }
コード例 #25
0
        public void Constructor_ValueAsProject_SetsProjectProperty()
        {
            var project                           = UnconfiguredProjectFactory.Create();
            var threadingService                  = new Lazy <IProjectThreadingService>(() => IProjectThreadingServiceFactory.Create());
            var projectProperties                 = ProjectPropertiesFactory.Create(project);
            var activeConfiguredProject           = IActiveConfiguredValueFactory.ImplementValue(() => projectProperties.ConfiguredProject);
            var activeConfiguredProjectProperties = IActiveConfiguredValueFactory.ImplementValue(() => projectProperties);
            var projectAccessor                   = new Lazy <IProjectAccessor>(() => IProjectAccessorFactory.Create());

            var services = new UnconfiguredProjectCommonServices(project, threadingService, activeConfiguredProject, activeConfiguredProjectProperties, projectAccessor);

            Assert.Same(project, services.Project);
        }
コード例 #26
0
 public void Constructor_NullAsConfiguredProject_ThrowsArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => CreateInstance(IPhysicalProjectTreeFactory.Create(),
                                                                SVsServiceProviderFactory.Create(), null, IProjectAccessorFactory.Create()));
 }
コード例 #27
0
        private DebugTokenReplacer CreateInstance()
        {
            var environmentHelper = _envHelper.Object;

            var activeDebugFramework = new Mock <IActiveDebugFrameworkServices>();

            activeDebugFramework.Setup(s => s.GetConfiguredProjectForActiveFrameworkAsync())
            .Returns(() => Task.FromResult <ConfiguredProject?>(ConfiguredProjectFactory.Create()));

            string projectFile = @"<Project>
                <PropertyGroup>
                    <msbuildProperty1>Property1</msbuildProperty1>
                    <msbuildProperty2>Property2</msbuildProperty2>
                    <msbuildProperty3>Property3</msbuildProperty3>
                    <msbuildProperty4>Property4</msbuildProperty4>
                    <msbuildProperty5>Property5</msbuildProperty5>
                    <msbuildProperty6>Property6</msbuildProperty6>
                </PropertyGroup>
                </Project>";

            return(new DebugTokenReplacer(environmentHelper, activeDebugFramework.Object, IProjectAccessorFactory.Create(projectFile)));
        }
        private static ConfigurationProjectConfigurationDimensionProvider CreateInstance(string projectXml)
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);

            return(new ConfigurationProjectConfigurationDimensionProvider(projectAccessor));
        }
        private static AvoidPersistingProjectGuidStorageProvider CreateInstance(ProjectRootElement projectXml)
        {
            var projectAccessor = IProjectAccessorFactory.Create(projectXml);

            return(new AvoidPersistingProjectGuidStorageProvider(projectAccessor, UnconfiguredProjectFactory.Create()));
        }