本文整理汇总了C#中VsPackageSourceProvider.LoadPackageSources方法的典型用法代码示例。如果您正苦于以下问题:C# VsPackageSourceProvider.LoadPackageSources方法的具体用法?C# VsPackageSourceProvider.LoadPackageSources怎么用?C# VsPackageSourceProvider.LoadPackageSources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VsPackageSourceProvider
的用法示例。
在下文中一共展示了VsPackageSourceProvider.LoadPackageSources方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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", ""));
}
示例11: SettingsWithMoreThanOneAggregateSourceAreModifiedToNotHaveOne
public void SettingsWithMoreThanOneAggregateSourceAreModifiedToNotHaveOne()
{
// 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(NuGetOfficialFeedName, sources[0].Name);
}
示例12: CtorAddsAggregrateIfNothingWasPersistedIntoSettingsManager
public void CtorAddsAggregrateIfNothingWasPersistedIntoSettingsManager()
{
// 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(NuGetOfficialFeedName, sources[0].Name);
}
示例13: CtorMigrateV1FeedToV2FeedAndPreserveIsEnabledProperty
public void CtorMigrateV1FeedToV2FeedAndPreserveIsEnabledProperty()
{
// Arrange
var userSettings = new Mock<ISettings>();
userSettings.Setup(s => s.GetSettingValues("packageSources", true))
.Returns(new[] { new SettingValue(NuGetLegacyOfficialFeedName, "https://go.microsoft.com/fwlink/?LinkID=206669", false) });
// disable the official source
userSettings.Setup(s => s.GetSettingValues("disabledPackageSources", false))
.Returns(new[] { new SettingValue(NuGetLegacyOfficialFeedName, "true", false) });
var provider = new VsPackageSourceProvider(userSettings.Object, CreateDefaultSourceProvider(userSettings.Object), new Mock<IVsShellInfo>().Object);
// Act
var sources = provider.LoadPackageSources().ToList();
// Assert
Assert.Equal(1, sources.Count);
Assert.Equal(NuGetOfficialFeedUrl, sources[0].Source);
Assert.Equal(NuGetOfficialFeedName, sources[0].Name);
Assert.False(sources[0].IsEnabled);
}
示例14: SettingsWithMoreThanOneAggregateSourceAreModifiedToNotHaveOne
public void SettingsWithMoreThanOneAggregateSourceAreModifiedToNotHaveOne()
{
// 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("NuGet official package source", sources[0].Name);
}
示例15: CtorAddsAggregrateIfNothingWasPersistedIntoSettingsManager
public void CtorAddsAggregrateIfNothingWasPersistedIntoSettingsManager()
{
// 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("NuGet official package source", sources[0].Name);
}