コード例 #1
0
        public void EnableCommandEnableDisabledSourcesCorrectly()
        {
            // Arrange
            var settings = new MockUserSettingsManager();
            settings.SetValues(PackageSourceProvider.PackageSourcesSectionName,
               new[] {
                    new KeyValuePair<string, string>("one", "onesource"),       // enabled
                    new KeyValuePair<string, string>("two", "twosource"),       // disabled
                    new KeyValuePair<string, string>("three", "threesource")    // enabled
                });
            settings.SetValues(PackageSourceProvider.DisabledPackageSourcesSectionName,
                new[] {
                    new KeyValuePair<string, string>("two", "true")
                });

            var packageSourceProvider = new PackageSourceProvider(settings);
            var command = new SourcesCommand(packageSourceProvider);
            command.Arguments.Add("Enable");
            command.Name = "two";
            command.Console = new Mock<IConsole>().Object;

            // Act
            command.ExecuteCommand();

            // Assert
            var packageSources = packageSourceProvider.LoadPackageSources().ToList();
            Assert.Equal(3, packageSources.Count);
            Assert.True(packageSources[0].IsEnabled);
            Assert.True(packageSources[1].IsEnabled);
            Assert.True(packageSources[2].IsEnabled);
        }
コード例 #2
0
        public void PreserveActiveSourceWhileMigratingNuGetFeed()
        {
            // Arrange
            var userSettingsManager = new MockUserSettingsManager();
            userSettingsManager.SetValues(
                PackageSourceProvider.PackageSourcesSectionName,
                new KeyValuePair<string, string>[] {
                    new KeyValuePair<string, string>("NuGet official package source", "https://go.microsoft.com/fwlink/?LinkID=206669"),
                    new KeyValuePair<string, string>("one", "onesource"),
                }
            );
            userSettingsManager.SetValue(VsPackageSourceProvider.ActivePackageSourceSectionName, "one", "onesource");

            var provider = new VsPackageSourceProvider(userSettingsManager);

            // Act
            var activeSource = provider.ActivePackageSource;

            // Assert
            AssertPackageSource(activeSource, "one", "onesource");
        }