public NewSubscriptionWindow(string topicFullName) :
            base(
                string.Format(
                    GoogleCloudExtension.Resources.NewSubscriptionWindowHeader,
                    PubsubDataSource.GetPathLeaf(topicFullName)))
        {
            Subscription model = new Subscription {
                Topic = topicFullName
            };

            ViewModel = new NewSubscriptionViewModel(model, this);
            Content   = new NewSubscriptionWindowContent(ViewModel);
        }
Пример #2
0
        public async Task TestDeleteSubscriptionAsyncSuccess()
        {
            var           responses = new[] { new Empty() };
            PubsubService service   = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Subscriptions,
                s => s.Delete(It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            await sourceUnderTest.DeleteSubscriptionAsync(SubscriptionFullName);

            var subscriptionsMock = Mock.Get(service.Projects.Subscriptions);

            subscriptionsMock.Verify(s => s.Delete(SubscriptionFullName), Times.Once);
            subscriptionsMock.Verify(s => s.Delete(It.IsNotIn(SubscriptionFullName)), Times.Never);
        }
Пример #3
0
        public async Task TestDeleteTopicAsyncSuccess()
        {
            var           responses = new[] { new Empty() };
            PubsubService service   = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Topics,
                t => t.Delete(It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            await sourceUnderTest.DeleteTopicAsync(TopicFullName);

            var topicMock = Mock.Get(service.Projects.Topics);

            topicMock.Verify(t => t.Delete(TopicFullName), Times.Once);
            topicMock.Verify(t => t.Delete(It.IsNotIn(TopicFullName)), Times.Never);
        }
Пример #4
0
        public async Task TestNewTopicAsyncSuccess()
        {
            var responses = new[] { new Topic {
                                        Name = MockedTopicName
                                    } };
            PubsubService service = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Topics,
                t => t.Create(It.IsAny <Topic>(), It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            var topic = await sourceUnderTest.NewTopicAsync(TopicName);

            Assert.AreEqual(MockedTopicName, topic.Name);
            var topicMock = Mock.Get(service.Projects.Topics);

            topicMock.Verify(t => t.Create(It.IsAny <Topic>(), TopicFullName), Times.Once);
            topicMock.Verify(t => t.Create(It.IsAny <Topic>(), It.IsNotIn(TopicFullName)), Times.Never);
        }
Пример #5
0
        public async Task TestNewSubscriptionAsyncSuccess()
        {
            var responses = new[] { new Subscription {
                                        Name = MockedSubscriptionName, Topic = MockedTopicName
                                    } };
            PubsubService service = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Subscriptions,
                s => s.Create(It.IsAny <Subscription>(), It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            var subscription = await sourceUnderTest.NewSubscriptionAsync(s_newSubscription);

            Assert.AreEqual(MockedSubscriptionName, subscription.Name);
            Assert.AreEqual(MockedTopicName, subscription.Topic);
            var subscriptionMock = Mock.Get(service.Projects.Subscriptions);

            subscriptionMock.Verify(s => s.Create(It.IsAny <Subscription>(), SubscriptionFullName), Times.Once);
            subscriptionMock.Verify(s => s.Create(It.IsAny <Subscription>(), It.IsNotIn(SubscriptionFullName)), Times.Never);
        }
Пример #6
0
        public async Task TestGetTopicListAsyncMultiPage()
        {
            var responses = new[]
            {
                new ListTopicsResponse
                {
                    NextPageToken = "Token",
                    Topics        = new List <Topic> {
                        new Topic {
                            Name = FirstName
                        }
                    }
                },
                new ListTopicsResponse
                {
                    Topics = new List <Topic> {
                        new Topic {
                            Name = SecondName
                        }
                    }
                }
            };
            PubsubService service = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Topics,
                t => t.List(It.IsAny <string>()),
                responses);

            var           sourceUnderTest = new PubsubDataSource(service, ProjectName);
            IList <Topic> topics          = await sourceUnderTest.GetTopicListAsync();

            Assert.AreEqual(2, topics.Count);
            Assert.AreEqual(FirstName, topics[0].Name);
            Assert.AreEqual(SecondName, topics[1].Name);
            var topicsMock = Mock.Get(service.Projects.Topics);

            topicsMock.Verify(t => t.List(ProjectResourceName), Times.AtLeastOnce);
            topicsMock.Verify(t => t.List(It.IsNotIn(ProjectResourceName)), Times.Never);
        }
Пример #7
0
        public async Task TestGetSubscriptionListAsyncPaged()
        {
            var responses = new[]
            {
                new ListSubscriptionsResponse
                {
                    NextPageToken = "Token",
                    Subscriptions = new List <Subscription> {
                        new Subscription {
                            Name = FirstName
                        }
                    }
                },
                new ListSubscriptionsResponse
                {
                    Subscriptions = new List <Subscription> {
                        new Subscription {
                            Name = SecondName
                        }
                    }
                }
            };
            PubsubService service = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Subscriptions,
                s => s.List(It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            IList <Subscription> subscriptions = await sourceUnderTest.GetSubscriptionListAsync();

            Assert.AreEqual(2, subscriptions.Count);
            Assert.AreEqual(FirstName, subscriptions[0].Name);
            Assert.AreEqual(SecondName, subscriptions[1].Name);
            var subscriptionsMock = Mock.Get(service.Projects.Subscriptions);

            subscriptionsMock.Verify(s => s.List(ProjectResourceName), Times.AtLeastOnce);
            subscriptionsMock.Verify(s => s.List(It.IsNotIn(ProjectResourceName)), Times.Never);
        }
Пример #8
0
        public async Task TestDeleteSubscriptionAsyncException()
        {
            var           responses = new Empty[0];
            PubsubService service   = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Subscriptions,
                s => s.Delete(It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            try
            {
                await sourceUnderTest.DeleteSubscriptionAsync(SubscriptionFullName);

                Assert.Fail();
            }
            finally
            {
                var subscriptionMock = Mock.Get(service.Projects.Subscriptions);
                subscriptionMock.Verify(s => s.Delete(SubscriptionFullName), Times.Once);
                subscriptionMock.Verify(s => s.Delete(It.IsNotIn(SubscriptionFullName)), Times.Never);
            }
        }
Пример #9
0
        public async Task TestNewTopicAsyncException()
        {
            var           responses = new Topic[0];
            PubsubService service   = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Topics,
                t => t.Create(It.IsAny <Topic>(), It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            try
            {
                await sourceUnderTest.NewTopicAsync(TopicName);

                Assert.Fail();
            }
            finally
            {
                var topicMock = Mock.Get(service.Projects.Topics);
                topicMock.Verify(t => t.Create(It.IsAny <Topic>(), TopicFullName), Times.Once);
                topicMock.Verify(t => t.Create(It.IsAny <Topic>(), It.IsNotIn(TopicFullName)), Times.Never);
            }
        }
Пример #10
0
        public async Task TestGetSubscriptionListAsyncException()
        {
            var           responses = new ListSubscriptionsResponse[0];
            PubsubService service   = GetMockedService(
                (PubsubService s) => s.Projects,
                p => p.Subscriptions,
                s => s.List(It.IsAny <string>()),
                responses);
            var sourceUnderTest = new PubsubDataSource(service, ProjectName);

            try
            {
                await sourceUnderTest.GetSubscriptionListAsync();

                Assert.Fail();
            }
            finally
            {
                var subscriptionsMock = Mock.Get(service.Projects.Subscriptions);
                subscriptionsMock.Verify(s => s.List(ProjectResourceName), Times.AtLeastOnce);
                subscriptionsMock.Verify(s => s.List(It.IsNotIn(ProjectResourceName)), Times.Never);
            }
        }