GetValues() public method

public GetValues ( string section ) : string>>.IList
section string
return string>>.IList
Ejemplo n.º 1
0
        public void AddSourceSetsPersistsSourcesToSettingsManager()
        {
            // Arrange
            var userSettingsManager     = new MockUserSettingsManager();
            var registrySettingsManager = new MockPackageSourceSettingsManager();
            var provider = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);

            // Act
            for (int i = 0; i < 10; i++)
            {
                provider.AddPackageSource(new PackageSource("source" + i, "name" + i));
            }

            // Assert
            var values = userSettingsManager.GetValues(VsPackageSourceProvider.FileSettingsSectionName);

            // 11 = 10 package sources that we added + NuGet offical source
            Assert.AreEqual(11, values.Count);
            Assert.AreEqual(Resources.VsResources.OfficialSourceName, values[0].Key);
            for (int i = 0; i < 10; i++)
            {
                AssertPackageSource(values[i + 1], "name" + i, "source" + i);
            }

            Assert.IsNull(registrySettingsManager.ActivePackageSourceString);
            Assert.IsNull(registrySettingsManager.PackageSourcesString);
        }
Ejemplo n.º 2
0
        public void RemovingExistingPackageSourceReturnsFalse()
        {
            // Arrange
            var userSettingsManager     = new MockUserSettingsManager();
            var registrySettingsManager = new MockPackageSourceSettingsManager();

            registrySettingsManager.PackageSourcesString = "<ArrayOfPackageSource xmlns=\"http://schemas.datacontract.org/2004/07/NuGet\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><PackageSource><IsAggregate>false</IsAggregate><Name>a</Name><Source>a</Source></PackageSource></ArrayOfPackageSource>";
            var provider      = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);
            var packageSource = new PackageSource("a", "a");

            // Act
            bool result = provider.RemovePackageSource(packageSource);

            // Assert
            Assert.IsTrue(result);

            // values should be null because we don't persist aggregate source into user settings file
            var values = userSettingsManager.GetValues(VsPackageSourceProvider.FileSettingsSectionName);

            Assert.IsNull(values);
        }
Ejemplo n.º 3
0
        public void PackageSourcesAreMigratedToUserSettings()
        {
            // Arrange
            var userSettingsManager     = new MockUserSettingsManager();
            var registrySettingsManager = new MockPackageSourceSettingsManager();

            registrySettingsManager.PackageSourcesString = "<ArrayOfPackageSource xmlns=\"http://schemas.datacontract.org/2004/07/NuGet\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><PackageSource><IsAggregate>false</IsAggregate><Name>name1</Name><Source>source1</Source></PackageSource><PackageSource><IsAggregate>false</IsAggregate><Name>name2</Name><Source>source2</Source></PackageSource><PackageSource><IsAggregate>false</IsAggregate><Name>name3</Name><Source>source3</Source></PackageSource></ArrayOfPackageSource>";
            var provider = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);

            // Act
            var values = userSettingsManager.GetValues(VsPackageSourceProvider.FileSettingsSectionName);

            // Assert
            Assert.AreEqual(3, values.Count);
            AssertPackageSource(values[0], "name1", "source1");
            AssertPackageSource(values[1], "name2", "source2");
            AssertPackageSource(values[2], "name3", "source3");

            // also verify that the registry setting is deleted
            Assert.IsNull(registrySettingsManager.PackageSourcesString);
        }
Ejemplo n.º 4
0
        public void SettingPackageSourcesWithAggregateWillNotAddAggregate()
        {
            // Arrange
            var userSettingsManager     = new MockUserSettingsManager();
            var registrySettingsManager = new MockPackageSourceSettingsManager();

            registrySettingsManager.PackageSourcesString = "";
            var provider       = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);
            var packageSources = new List <PackageSource> {
                provider.AggregateSource,
                new PackageSource("source", "name")
            };

            // Act
            provider.SetPackageSources(packageSources);

            // Assert
            var values = userSettingsManager.GetValues(VsPackageSourceProvider.FileSettingsSectionName);

            Assert.AreEqual(1, values.Count);
            AssertPackageSource(values[0], "name", "source");
        }