internal DescribeSubscriptionFiltersResponse DescribeSubscriptionFilters(DescribeSubscriptionFiltersRequest request) { var marshaller = new DescribeSubscriptionFiltersRequestMarshaller(); var unmarshaller = DescribeSubscriptionFiltersResponseUnmarshaller.Instance; return(Invoke <DescribeSubscriptionFiltersRequest, DescribeSubscriptionFiltersResponse>(request, marshaller, unmarshaller)); }
public async Task DescribeSubscriptionFiltersTest_TwoResponses() { var request = new DescribeSubscriptionFiltersRequest(); var firstResponse = new DescribeSubscriptionFiltersResponse() { NextToken = "foo" }; var secondResponse = new DescribeSubscriptionFiltersResponse() { NextToken = null }; var token = new CancellationToken(); _mockClient.SetupSequence(x => x.DescribeSubscriptionFiltersAsync(It.IsAny <DescribeSubscriptionFiltersRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(firstResponse) .ReturnsAsync(secondResponse); var numResponses = 0; await foreach (var desination in _mockClient.Object.Paginators.DescribeSubscriptionFilters(request).Responses.WithCancellation(token)) { numResponses += 1; } Assert.Equal(2, numResponses); }
public async Task DescribeSubscriptionFiltersTest__OnlyUsedOnce() { var request = new DescribeSubscriptionFiltersRequest(); var response = new DescribeSubscriptionFiltersResponse(); var token = new CancellationToken(); var paginator = _mockClient.Object.Paginators.DescribeSubscriptionFilters(request); _mockClient.Setup(x => x.DescribeSubscriptionFiltersAsync(It.IsAny <DescribeSubscriptionFiltersRequest>(), It.IsAny <CancellationToken>())).ReturnsAsync(response); // Should work the first time await LoopOverSubscriptionFilters(paginator, token); // Second time should throw an exception await Assert.ThrowsAsync <System.InvalidOperationException>(async() => await LoopOverSubscriptionFilters(paginator, token)); }
public async Task DescribeSubscriptionFiltersTest__CancellationToken() { var request = new DescribeSubscriptionFiltersRequest(); var firstResponse = new DescribeSubscriptionFiltersResponse() { NextToken = "foo" }; var secondResponse = new DescribeSubscriptionFiltersResponse() { NextToken = null }; var paginator = _mockClient.Object.Paginators.DescribeSubscriptionFilters(request); var tokenSource = new CancellationTokenSource(); var token = tokenSource.Token; tokenSource.Cancel(); _mockClient.SetupSequence(x => x.DescribeSubscriptionFiltersAsync(It.IsAny <DescribeSubscriptionFiltersRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(firstResponse) .ReturnsAsync(secondResponse); await Assert.ThrowsAsync <OperationCanceledException>(async() => await LoopOverSubscriptionFilters(paginator, token)); }
/// <summary> /// Initiates the asynchronous execution of the DescribeSubscriptionFilters operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DescribeSubscriptionFilters operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DescribeSubscriptionFiltersResponse> DescribeSubscriptionFiltersAsync(DescribeSubscriptionFiltersRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DescribeSubscriptionFiltersRequestMarshaller(); var unmarshaller = DescribeSubscriptionFiltersResponseUnmarshaller.Instance; return(InvokeAsync <DescribeSubscriptionFiltersRequest, DescribeSubscriptionFiltersResponse>(request, marshaller, unmarshaller, cancellationToken)); }