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


C# VsPackageSourceProvider.SavePackageSources方法代码示例

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


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

示例1: SavePackageSourcesWillNotSaveTheWindows8ExpressFeedWhenRunningWindows8Express

        public void SavePackageSourcesWillNotSaveTheWindows8ExpressFeedWhenRunningWindows8Express()
        {
            // 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
            provider.SavePackageSources(packageSources);

            // Assert
            // the Win8ExpressFeed is saved as active source, but not saved
            // in <packageSources>.
            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>
  <activePackageSource>
    <add key=""Windows 8 Packages"" value=""https://www.nuget.org/api/v2/curated-feeds/windows8-packages/"" />
  </activePackageSource>
</configuration>".Replace("\r", ""),
                  configFileContent.Replace("\r", ""));
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:37,代码来源:VsPackageSourceProviderTest.cs

示例2: 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

示例3: 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

示例4: SavePackageSourcesWillNotSwapInTheDefaultFeedForTheWindows8ExpressFeedWhenNotRunningWindows8Express

        public void SavePackageSourcesWillNotSwapInTheDefaultFeedForTheWindows8ExpressFeedWhenNotRunningWindows8Express()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            var vsShellInfo = new Mock<IVsShellInfo>();
            vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(false);
            var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object);

            // Act
            provider.SavePackageSources(new[]
            {
                new PackageSource("theFirstSource", "theFirstFeed"),
                new PackageSource("https://nuget.org/api/v2/curated-feeds/express-for-windows8/", "Visual Studio Express for Windows 8 official package source"){ IsOfficial = true },
                new PackageSource("theThirdSource", "theThirdFeed"),
            });

            // Assert
            packageSourceProvider.Verify(_ => _.SavePackageSources(It.Is<IEnumerable<PackageSource>>(packageSources => packageSources.ElementAt(1).Name == "Visual Studio Express for Windows 8 official package source")));
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:20,代码来源:VsPackageSourceProviderTest.cs

示例5: SavePackageSourcesWillSaveTheWindows8ExpressFeedWhenNotRunningWindows8Express

        public void SavePackageSourcesWillSaveTheWindows8ExpressFeedWhenNotRunningWindows8Express()
        {
            // Arrange
            var userSettings = new Mock<ISettings>();
            var packageSourceProvider = new Mock<IPackageSourceProvider>();
            var vsShellInfo = new Mock<IVsShellInfo>();
            vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(false);
            var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object);

            IList<PackageSource> savedSources = null;
            packageSourceProvider.Setup(_ => _.SavePackageSources(It.IsAny<IEnumerable<PackageSource>>()))
                                 .Callback((IEnumerable<PackageSource> _) => savedSources = _.ToList())
                                 .Verifiable();

            // Act
            provider.SavePackageSources(new[]
                {
                    new PackageSource("theFirstSource", "theFirstFeed"),
                    new PackageSource("https://nuget.org/api/v2/curated-feeds/windows8-packages/", "Windows 8 Packages"){ IsOfficial = true },
                    new PackageSource("theThirdSource", "theThirdFeed"),
                });

            // Assert
            Assert.NotNull(savedSources);
            Assert.Equal(3, savedSources.Count);
            AssertPackageSource(savedSources[0], "theFirstFeed", "theFirstSource");
            AssertPackageSource(savedSources[1], "Windows 8 Packages", "https://nuget.org/api/v2/curated-feeds/windows8-packages/");
            AssertPackageSource(savedSources[2], "theThirdFeed", "theThirdSource");
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:29,代码来源:VsPackageSourceProviderTest.cs

示例6: RemovingActivePackageSourceSetsActivePackageSourceToNull

        public void RemovingActivePackageSourceSetsActivePackageSourceToNull()
        {
            // Arrange
            var userSettingsManager = new MockUserSettingsManager();
            var packageSourceProvider = new MockPackageSourceProvider();
            var provider = new VsPackageSourceProvider(userSettingsManager, packageSourceProvider);
            var packageSource = new PackageSource("a", "a");
            provider.SavePackageSources(new[] { packageSource });
            provider.ActivePackageSource = packageSource;

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

            // Assert
            Assert.True(result);
            Assert.Null(provider.ActivePackageSource);

            // values should be null because we don't persist aggregate source into user settings file
            var values = userSettingsManager.GetValues(PackageSourceProvider.PackageSourcesSectionName);
            Assert.Null(values);
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:21,代码来源:VsPackageSourceProviderTest.cs


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