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); }
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); } }