Пример #1
0
        public void WithNoScope_AddsSourceToSessionScope()
        {
            // Arrange
            AddPackageSourceCommand cmd = new AddPackageSourceCommand().AutoConfigure();
            var mockService = new Mock<PackageSourceService>(MockBehavior.Strict) { CallBase = true };
            InMemorySourceStore sessionStore = new InMemorySourceStore();

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

            cmd.Name = "Foo";
            cmd.Source = "http://foo.bar";

            // Act
            cmd.Execute();

            // Assert
            Assert.Equal(new PackageSource("http://foo.bar", "Foo"), sessionStore.Sources.Single());
        }
Пример #2
0
        public void WhenScopeParameterSpecified_AddsSourceToMatchingList(PackageSourceScope scope, Expression<Func<PackageSourceService, IPackageSourceStore>> storeSelector)
        {
            // Arrange
            AddPackageSourceCommand cmd = new AddPackageSourceCommand().AutoConfigure();
            var mockService = new Mock<PackageSourceService>() { CallBase = true };
            cmd.SourceService = mockService.Object;
            cmd.Scope = scope;
            InMemorySourceStore store = new InMemorySourceStore();

            mockService.Setup(storeSelector).Returns(store);
            cmd.Source = "http://foo.bar";
            cmd.Name = "Foo";

            // Act
            cmd.Execute();

            // Assert
            Assert.Equal(new PackageSource("http://foo.bar", "Foo"), store.Sources.Single());
        }