Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
            }
        }