Inheritance: PackageSourceCommand
        public void WhenNoMatchingSourceInList_ThrowsKeyNotFoundException(PackageSourceScope scope, Expression<Func<PackageSourceService, IPackageSourceStore>> storeSelector)
        {
            // Arrange
            RemovePackageSourceCommand cmd = new RemovePackageSourceCommand().AutoConfigure();
            var mockService = new Mock<PackageSourceService>() { CallBase = true };
            cmd.SourceService = mockService.Object;
            cmd.Scope = scope;
            InMemorySourceStore store = new InMemorySourceStore(new[] {
                new PackageSource("http://foo.bar", "Bar")
            });

            mockService.Setup(storeSelector).Returns(store);
            cmd.Name = "Foo";

            // Act
            Assert.Throws<KeyNotFoundException>(() => cmd.Execute());

            // Assert
            Assert.Equal(new PackageSource("http://foo.bar", "Bar"), store.Sources.Single());
        }
        public void WhenScopeParameterSpecified_RemovesSourceFromMatchingList(PackageSourceScope scope, Expression<Func<PackageSourceService, IPackageSourceStore>> storeSelector)
        {
            // Arrange
            RemovePackageSourceCommand cmd = new RemovePackageSourceCommand().AutoConfigure();
            var mockService = new Mock<PackageSourceService>() { CallBase = true };
            cmd.SourceService = mockService.Object;
            cmd.Scope = scope;
            InMemorySourceStore store = new InMemorySourceStore(new [] {
                new PackageSource("http://foo.bar", "Foo")
            });

            mockService.Setup(storeSelector).Returns(store);
            cmd.Name = "Foo";

            // Act
            cmd.Execute();

            // Assert
            Assert.False(store.Sources.Any());
        }
        public void WithNoScope_RemovesSourceFromSessionScope()
        {
            // Arrange
            RemovePackageSourceCommand cmd = new RemovePackageSourceCommand().AutoConfigure();
            var mockService = new Mock<PackageSourceService>(MockBehavior.Strict) { CallBase = true };
            InMemorySourceStore sessionStore = new InMemorySourceStore(new[] {
                new PackageSource("http://foo.bar", "Foo")
            });

            cmd.SourceService = mockService.Object;
            mockService.Setup(s => s.SessionStore).Returns(sessionStore);

            cmd.Name = "Foo";

            // Act
            cmd.Execute();

            // Assert
            Assert.False(sessionStore.Sources.Any());
        }