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(4, sources.Count); Assert.Equal("https://test2", sources[0].Source); Assert.Equal(NuGetOfficialFeedUrl, sources[2].Source); Assert.False(sources[2].IsEnabled); Assert.Equal("https://test1", sources[3].Source); }
public void LoadPackageSourcesWillAddTheWindows8SourceAtTheFrontWhenRunningWindows8Express() { // Arrange var mockFileSystem = new MockFileSystem(); mockFileSystem.AddFile("nuget.config", @"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <packageSources> <add key=""a"" value=""http://a"" /> </packageSources> </configuration>"); 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); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(2, sources.Count); AssertPackageSource(sources[0], "Windows 8 Packages", NuGetConstants.VSExpressForWindows8FeedUrl); AssertPackageSource(sources[1], "a", "http://a"); }
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); }
public void LoadPackageSourcesWillNotAddTheWindows8SourceWhenNotRunningWindows8Express() { // Arrange var userSettings = new Mock <ISettings>(); var packageSourceProvider = new Mock <IPackageSourceProvider>(); packageSourceProvider.Setup(_ => _.LoadPackageSources()).Returns(new[] { new PackageSource("theFirstSource", "theFirstFeed"), new PackageSource(NuGetOfficialFeedUrl, NuGetOfficialFeedName), new PackageSource("theThirdSource", "theThirdFeed"), }); var vsShellInfo = new Mock <IVsShellInfo>(); vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(false); var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(3, sources.Count); AssertPackageSource(sources[0], "theFirstFeed", "theFirstSource"); AssertPackageSource(sources[1], NuGetOfficialFeedName, NuGetOfficialFeedUrl); AssertPackageSource(sources[2], "theThirdFeed", "theThirdSource"); }
public void LoadPackageSourcesWillAddTheWindows8SourceAtTheFrontWhenRunningWindows8Express() { // Arrange var userSettings = new Mock <ISettings>(); var packageSourceProvider = new Mock <IPackageSourceProvider>(); packageSourceProvider.Setup(_ => _.LoadPackageSources()).Returns(new[] { new PackageSource("theFirstSource", "theFirstFeed"), new PackageSource("https://nuget.org/api/v2/", "NuGet official package source"), new PackageSource("theThirdSource", "theThirdFeed"), }); var vsShellInfo = new Mock <IVsShellInfo>(); vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(true); var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(4, sources.Count); AssertPackageSource(sources[0], "Windows 8 Packages", NuGetConstants.VSExpressForWindows8FeedUrl); AssertPackageSource(sources[1], "theFirstFeed", "theFirstSource"); AssertPackageSource(sources[2], "NuGet official package source", "https://nuget.org/api/v2/"); AssertPackageSource(sources[3], "theThirdFeed", "theThirdSource"); }
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); }
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); }
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(2, sources.Count); Assert.Equal(NuGetOfficialFeedName, sources[1].Name); }
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("https://nuget.org/api/v2/", sources[0].Source); }
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); }
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(2, sources.Count); Assert.Equal(NuGetOfficialFeedName, sources[1].Name); }
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(2, sources.Count); Assert.Equal(NuGetOfficialFeedUrl, sources[1].Source); }
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); }
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); }
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); }
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(2, sources.Count); Assert.Equal(NuGetOfficialFeedUrl, sources[0].Source); }
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); }
public void CtorMigratesEvenCaseDoesNotMatch() { // Arrange var userSettings = new Mock <ISettings>(); userSettings.Setup(s => s.GetSettingValues("packageSources", true)) .Returns(new[] { new SettingValue("NuGET oFFIcial PACKAGE souRCe", "HTTPS://nUGet.org/ApI/V2/", 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(2, sources.Count); Assert.Equal(NuGetOfficialFeedUrl, sources[0].Source); Assert.Equal(NuGetOfficialFeedName, sources[0].Name); }
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); }
public void LoadPackageSourcesWillNotAddTheWindows8SourceWhenNotRunningWindows8Express() { // 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(false); var provider = new VsPackageSourceProvider(settings, packageSourceProvider, vsShellInfo.Object); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(0, sources.Count); }
public void LoadPackageSourcesAddOfficialSourceIfMissing() { // Arrange var userSettings = new Mock <ISettings>(); userSettings.Setup(s => s.GetSettingValues("packageSources", true)) .Returns(new[] { new SettingValue("my source", "http://www.nuget.org", 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); AssertPackageSource(sources[0], "my source", "http://www.nuget.org"); AssertPackageSource(sources[2], NuGetOfficialFeedName, NuGetOfficialFeedUrl); Assert.False(sources[1].IsEnabled); Assert.True(sources[1].IsOfficial); }
public void LoadPackageSourcesAddOfficialSourceIfMissing() { // Arrange var userSettings = new Mock <ISettings>(); userSettings.Setup(s => s.GetValues("packageSources")) .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); }
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); }
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); }
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", "")); }
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", "")); }
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.GetValues("disabledPackageSources")) .Returns(new[] { new KeyValuePair <string, string>(NuGetLegacyOfficialFeedName, "true") }); var provider = new VsPackageSourceProvider(userSettings.Object, CreateDefaultSourceProvider(userSettings.Object), new Mock <IVsShellInfo>().Object); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(2, sources.Count); Assert.Equal(NuGetOfficialFeedUrl, sources[0].Source); Assert.Equal(NuGetOfficialFeedName, sources[0].Name); Assert.False(sources[0].IsEnabled); }
public void LoadPackageSourcesWillNotAddTheWindows8SourceWhenNotRunningWindows8Express() { // Arrange var userSettings = new Mock<ISettings>(); var packageSourceProvider = new Mock<IPackageSourceProvider>(); packageSourceProvider.Setup(_ => _.LoadPackageSources()).Returns(new[] { new PackageSource("theFirstSource", "theFirstFeed"), new PackageSource(NuGetOfficialFeedUrl, NuGetOfficialFeedName), new PackageSource("theThirdSource", "theThirdFeed"), }); var vsShellInfo = new Mock<IVsShellInfo>(); vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(false); var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(3, sources.Count); AssertPackageSource(sources[0], "theFirstFeed", "theFirstSource"); AssertPackageSource(sources[1], NuGetOfficialFeedName, NuGetOfficialFeedUrl); AssertPackageSource(sources[2], "theThirdFeed", "theThirdSource"); }
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); }
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", "")); }
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); }
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); }
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); }
public void LoadPackageSourcesAddOfficialSourceIfMissing() { // Arrange var userSettings = new Mock<ISettings>(); userSettings.Setup(s => s.GetSettingValues("packageSources", true)) .Returns(new[] { new SettingValue("my source", "http://www.nuget.org", 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(2, sources.Count); AssertPackageSource(sources[0], "my source", "http://www.nuget.org"); AssertPackageSource(sources[1], NuGetOfficialFeedName, NuGetOfficialFeedUrl); Assert.False(sources[1].IsEnabled); Assert.True(sources[1].IsOfficial); }
public void DefaultSourceAddedAndEnabled() { // 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", true) }); 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(NuGetOfficialFeedUrl, sources[0].Source); Assert.True(sources[0].IsEnabled); }
public void LoadPackageSourcesWillNotSwapInTheWindows8SourceForTheDefaultSourceWhenNotRunningWindows8Express() { // Arrange var userSettings = new Mock<ISettings>(); var packageSourceProvider = new Mock<IPackageSourceProvider>(); packageSourceProvider.Setup(_ => _.LoadPackageSources()).Returns(new[] { new PackageSource("theFirstSource", "theFirstFeed"), new PackageSource("https://nuget.org/api/v2/", "NuGet official package source"), new PackageSource("theThirdSource", "theThirdFeed"), }); var vsShellInfo = new Mock<IVsShellInfo>(); vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(false); var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object); // Act var sources = provider.LoadPackageSources(); // Assert Assert.Equal("NuGet official package source", sources.ElementAt(1).Name); }
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); }
public void LoadPackageSourcesWillAddTheWindows8SourceAtTheFrontWhenRunningWindows8Express() { // Arrange var mockFileSystem = new MockFileSystem(); mockFileSystem.AddFile("nuget.config", @"<?xml version=""1.0"" encoding=""utf-8""?> <configuration> <packageSources> <add key=""a"" value=""http://a"" /> </packageSources> </configuration>"); 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); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(2, sources.Count); AssertPackageSource(sources[0], "Windows 8 Packages", NuGetConstants.VSExpressForWindows8FeedUrl); AssertPackageSource(sources[1], "a", "http://a"); }
public void LoadPackageSourcesWillAddTheWindows8SourceAtTheFrontWhenRunningWindows8Express() { // Arrange var userSettings = new Mock<ISettings>(); var packageSourceProvider = new Mock<IPackageSourceProvider>(); packageSourceProvider.Setup(_ => _.LoadPackageSources()).Returns(new[] { new PackageSource("theFirstSource", "theFirstFeed"), new PackageSource("https://nuget.org/api/v2/", "NuGet official package source"), new PackageSource("theThirdSource", "theThirdFeed"), }); var vsShellInfo = new Mock<IVsShellInfo>(); vsShellInfo.Setup(_ => _.IsVisualStudioExpressForWindows8).Returns(true); var provider = new VsPackageSourceProvider(userSettings.Object, packageSourceProvider.Object, vsShellInfo.Object); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(4, sources.Count); AssertPackageSource(sources[0], "Windows 8 Packages", NuGetConstants.VSExpressForWindows8FeedUrl); AssertPackageSource(sources[1], "theFirstFeed", "theFirstSource"); AssertPackageSource(sources[2], "NuGet official package source", "https://nuget.org/api/v2/"); AssertPackageSource(sources[3], "theThirdFeed", "theThirdSource"); }
public void LoadPackageSourcesWillNotAddTheWindows8SourceWhenNotRunningWindows8Express() { // 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(false); var provider = new VsPackageSourceProvider(settings, packageSourceProvider, vsShellInfo.Object); // Act var sources = provider.LoadPackageSources().ToList(); // Assert Assert.Equal(0, sources.Count); }
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", "")); }
public void CtorMigratesEvenCaseDoesNotMatch() { // Arrange var userSettings = new Mock<ISettings>(); userSettings.Setup(s => s.GetSettingValues("packageSources", true)) .Returns(new[] { new SettingValue("NuGET oFFIcial PACKAGE souRCe", "HTTPS://nUGet.org/ApI/V2/", 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); Assert.Equal(NuGetOfficialFeedName, sources[0].Name); }
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); }