当前位置: 首页>>代码示例>>C#>>正文


C# VsPackageSourceProvider类代码示例

本文整理汇总了C#中VsPackageSourceProvider的典型用法代码示例。如果您正苦于以下问题:C# VsPackageSourceProvider类的具体用法?C# VsPackageSourceProvider怎么用?C# VsPackageSourceProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VsPackageSourceProvider类属于命名空间,在下文中一共展示了VsPackageSourceProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddSourceSetsPersistsSourcesToSettingsManager

        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);
        }
开发者ID:grendello,项目名称:nuget,代码行数:25,代码来源:VsPackageSourceProviderTest.cs

示例2: CtorMigrateV1FeedToV2FeedAndPreserveIsEnabledProperty

        public void CtorMigrateV1FeedToV2FeedAndPreserveIsEnabledProperty()
        {
            // Arrange
            var userSettingsManager = new MockUserSettingsManager();
            userSettingsManager.SetValue(
                PackageSourceProvider.PackageSourcesSectionName,
                "NuGet official package source",
                "https://go.microsoft.com/fwlink/?LinkID=206669");

            // disable the official source
            userSettingsManager.SetValue(
                PackageSourceProvider.DisabledPackageSourcesSectionName,
                "NuGet official package source",
                "true");

            var provider = new VsPackageSourceProvider(userSettingsManager);

            // Act
            var sources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(1, sources.Count);
            Assert.Equal("https://go.microsoft.com/fwlink/?LinkID=230477", sources[0].Source);
            Assert.False(sources[0].IsEnabled);
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:25,代码来源:VsPackageSourceProviderTest.cs

示例3: DefaultSourceAddedButDisabled

        public void DefaultSourceAddedButDisabled()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            userSettings.Setup(s => s.GetSettingValues("packageSources", true))
                        .Returns(new[] { 
                            new SettingValue("Test1", "https://test1", true),
                            new SettingValue("Test2", "https://test2", false) 
                        });
            var sourceProvider = CreateDefaultSourceProvider(userSettings.Object);
            var provider = new VsPackageSourceProvider(userSettings.Object, sourceProvider, new Mock<IVsShellInfo>().Object);

            // Act
            var sources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(3, sources.Count);

            Assert.Equal("https://test2", sources[0].Source);

            Assert.Equal("https://nuget.org/api/v2/", sources[1].Source);
            Assert.False(sources[1].IsEnabled);
            
            Assert.Equal("https://test1", sources[2].Source);
        }
开发者ID:kumavis,项目名称:NuGet,代码行数:25,代码来源:VsPackageSourceProviderTest.cs

示例4: AddSourceThrowsIfSourceIsNull

        public void AddSourceThrowsIfSourceIsNull()
        {
            // Arrange
            var registrySettingsManager = new MockPackageSourceSettingsManager();
            var userSettingsManager = new MockUserSettingsManager();
            var provider = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);

            // Act
            ExceptionAssert.ThrowsArgNull(() => provider.AddPackageSource(null), "source");
        }
开发者ID:grendello,项目名称:nuget,代码行数:10,代码来源:VsPackageSourceProviderTest.cs

示例5: CtorIfFirstRunningAddsDefaultSource

        public void CtorIfFirstRunningAddsDefaultSource()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            var packageSourceProvider = CreateDefaultSourceProvider(userSettings.Object);
            var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider, new Mock<IVsShellInfo>().Object);

            // Act
            var sources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(1, sources.Count);
            Assert.Equal(NuGetOfficialFeedUrl, sources[0].Source);
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:14,代码来源:VsPackageSourceProviderTest.cs

示例6: AggregateSourceWithoutIsAggregateFlagSetFlagToTrue

        public void AggregateSourceWithoutIsAggregateFlagSetFlagToTrue()
        {
            // 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><Name>All</Name><Source>(Aggregate source)</Source></PackageSource><PackageSource><IsAggregate>false</IsAggregate><Name>NuGet official package source</Name><Source>https://go.microsoft.com/fwlink/?LinkID=206669</Source></PackageSource></ArrayOfPackageSource>";
            var provider = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);

            // Act
            var sources = provider.GetPackageSources().ToList();

            // Assert
            Assert.AreEqual(2, sources.Count);
            Assert.IsTrue(sources[0].IsAggregate);
        }
开发者ID:grendello,项目名称:nuget,代码行数:15,代码来源:VsPackageSourceProviderTest.cs

示例7: CtorIfFirstRunningAddsDefaultSource

        public void CtorIfFirstRunningAddsDefaultSource()
        {
            // Arrange
            var userSettingsManager = new MockUserSettingsManager();
            var packageSourceProvider = new MockPackageSourceProvider();
            var provider = new VsPackageSourceProvider(userSettingsManager, packageSourceProvider);

            // Act
            var sources = provider.LoadPackageSources().ToList();


            // Assert
            Assert.Equal(1, sources.Count);
            Assert.Equal("https://go.microsoft.com/fwlink/?LinkID=230477", sources[0].Source);
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:15,代码来源:VsPackageSourceProviderTest.cs

示例8: CtorMigrateV2LegacyFeedToV2Feed

        public void CtorMigrateV2LegacyFeedToV2Feed()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            userSettings.Setup(s => s.GetValues("packageSources"))
                        .Returns(new[] { new KeyValuePair<string, string>("NuGet official package source", "https://go.microsoft.com/fwlink/?LinkID=230477") });
            var sourceProvider = CreateDefaultSourceProvider(userSettings.Object);
            var provider = new VsPackageSourceProvider(userSettings.Object, sourceProvider, new Mock<IVsShellInfo>().Object);

            // Act
            var sources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(1, sources.Count);
            Assert.Equal("https://nuget.org/api/v2/", sources[0].Source);
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:16,代码来源:VsPackageSourceProviderTest.cs

示例9: CtorMigrateV2LegacyFeedToV2Feed

        public void CtorMigrateV2LegacyFeedToV2Feed()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            userSettings.Setup(s => s.GetSettingValues("packageSources", true))
                        .Returns(new[] { new SettingValue(NuGetLegacyOfficialFeedName, "https://go.microsoft.com/fwlink/?LinkID=230477", false) });
            var sourceProvider = CreateDefaultSourceProvider(userSettings.Object);
            var provider = new VsPackageSourceProvider(userSettings.Object, sourceProvider, new Mock<IVsShellInfo>().Object);

            // Act
            var sources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(1, sources.Count);
            Assert.Equal(NuGetOfficialFeedUrl, sources[0].Source);
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:16,代码来源:VsPackageSourceProviderTest.cs

示例10: LoadPackageSourcesAddOfficialSourceIfMissing

        public void LoadPackageSourcesAddOfficialSourceIfMissing()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            userSettings.Setup(s => s.GetValues("packageSources", true))
                        .Returns(new[] { new KeyValuePair<string, string>("my source", "http://nuget.org") });
            var sourceProvider = CreateDefaultSourceProvider(userSettings.Object);
            var provider = new VsPackageSourceProvider(userSettings.Object, sourceProvider, new Mock<IVsShellInfo>().Object);

            // Act
            var sources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(2, sources.Count);
            AssertPackageSource(sources[0], "my source", "http://nuget.org");
            AssertPackageSource(sources[1], "NuGet official package source", "https://nuget.org/api/v2/");
            Assert.False(sources[1].IsEnabled);
            Assert.True(sources[1].IsOfficial);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:19,代码来源:VsPackageSourceProviderTest.cs

示例11: ActivePackageSourceIsMigratedToUserSettings

        public void ActivePackageSourceIsMigratedToUserSettings()
        {
            // 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>";
            registrySettingsManager.ActivePackageSourceString = "<PackageSource xmlns=\"http://schemas.datacontract.org/2004/07/NuGet\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><IsAggregate>false</IsAggregate><Name>name2</Name><Source>source2</Source></PackageSource>";

            // Act
            var provider = new VsPackageSourceProvider(registrySettingsManager, userSettingsManager);

            // Assert
            var activeValue = userSettingsManager.GetValue(VsPackageSourceProvider.FileSettingsActiveSectionName, "name2");
            Assert.AreEqual("source2", activeValue);

            var invalidActiveValue = userSettingsManager.GetValue(VsPackageSourceProvider.FileSettingsActiveSectionName, "invalidName");
            Assert.IsNull(invalidActiveValue);

            // also verify that the registry setting is deleted
            Assert.IsNull(registrySettingsManager.ActivePackageSourceString);
        }
开发者ID:grendello,项目名称:nuget,代码行数:21,代码来源:VsPackageSourceProviderTest.cs

示例12: CtorMigrateV1FeedToV2FeedAndPreserveIsEnabledProperty

        public void CtorMigrateV1FeedToV2FeedAndPreserveIsEnabledProperty()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            userSettings.Setup(s => s.GetValues("packageSources"))
                        .Returns(new[] { new KeyValuePair<string, string>("NuGet official package source", "https://go.microsoft.com/fwlink/?LinkID=206669") });

            // disable the official source
            userSettings.Setup(s => s.GetValues("disabledPackageSources"))
                        .Returns(new[] { new KeyValuePair<string, string>("NuGet official package source", "true") });

            var provider = new VsPackageSourceProvider(userSettings.Object, new Mock<IVsShellInfo>().Object);

            // Act
            var sources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(1, sources.Count);
            Assert.Equal("https://nuget.org/api/v2/", sources[0].Source);
            Assert.False(sources[0].IsEnabled);
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:21,代码来源:VsPackageSourceProviderTest.cs

示例13: TheEnabledStateOfWindows8FeedIsRestoredWhenRunningOnWindows8Express

        public void TheEnabledStateOfWindows8FeedIsRestoredWhenRunningOnWindows8Express()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            packageSourceProvider.Setup(_ => _.LoadPackageSources()).Returns(new PackageSource[]
                {
                    new PackageSource("source", "name"),
                    new PackageSource("theFirstSource", "theFirstFeed", isEnabled: true)
                });

            var vsShellInfo = new Mock<IVsShellInfo>();
            vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(true);
            var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object);
            packageSourceProvider.Setup(p => p.IsPackageSourceEnabled(
                                                It.Is<PackageSource>(ps => ps.Name.Equals("Windows 8 packages", StringComparison.OrdinalIgnoreCase))))
                                 .Returns(false);

            // Act
            var packageSources = provider.LoadPackageSources().ToList();

            // Assert
            Assert.Equal(3, packageSources.Count);
            AssertPackageSource(packageSources[0], "Windows 8 Packages", NuGetConstants.VSExpressForWindows8FeedUrl);
            Assert.False(packageSources[0].IsEnabled);
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:26,代码来源:VsPackageSourceProviderTest.cs

示例14: TheEnabledStateOfWindows8FeedIsNotPersistedWhenRunningOnWindows8Express

        public void TheEnabledStateOfWindows8FeedIsNotPersistedWhenRunningOnWindows8Express()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            var packageSourceProvider = new Mock<IPackageSourceProvider>();

            var vsShellInfo = new Mock<IVsShellInfo>();
            vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(true);
            var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object);

            // Act
            var packageSources = new PackageSource[]
            {
                new PackageSource(NuGetConstants.VSExpressForWindows8FeedUrl, "Windows 8 packages", isEnabled: true, isOfficial: true)
            };
            provider.SavePackageSources(packageSources);

            // Assert
            packageSourceProvider.Verify(p => p.DisablePackageSource(It.IsAny<PackageSource>()), Times.Never());
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:20,代码来源:VsPackageSourceProviderTest.cs

示例15: TheDisabledStateOfWindows8FeedIsPersistedWhenRunningOnWindows8Express

        public void TheDisabledStateOfWindows8FeedIsPersistedWhenRunningOnWindows8Express()
        {
            // Arrange
            var mockFileSystem = new MockFileSystem();
            var settings = Settings.LoadDefaultSettings(
                mockFileSystem,
                configFileName: null,
                machineWideSettings: null);
            var packageSourceProvider = new PackageSourceProvider(settings);
            var vsShellInfo = new Mock<IVsShellInfo>();
            vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(true);
            var provider = new VsPackageSourceProvider(settings, packageSourceProvider, vsShellInfo.Object);
            var packageSources = provider.LoadPackageSources().ToList();

            Assert.Equal(1, packageSources.Count);
            Assert.Equal(NuGetConstants.VSExpressForWindows8FeedUrl, packageSources[0].Source);
            Assert.True(packageSources[0].IsEnabled);

            // Act
            packageSources[0].IsEnabled = false;
            provider.SavePackageSources(packageSources);

            // Assert
            // the Win8ExpressFeed is not saved in <disabledPackageSources>.
            Assert.Equal(1, mockFileSystem.Paths.Count);
            var configFile = mockFileSystem.Paths.First().Key;
            var configFileContent = mockFileSystem.ReadAllText(configFile);

            Assert.Equal(
                @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <packageSources />
  <disabledPackageSources>
    <add key=""Windows 8 Packages"" value=""true"" />
  </disabledPackageSources>
</configuration>".Replace("\r", ""),
                  configFileContent.Replace("\r", ""));
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:38,代码来源:VsPackageSourceProviderTest.cs


注:本文中的VsPackageSourceProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。