public async Task GetSubscriptionsAsync_ThrowsExceptionWhenTapioReturnsErrorCode() { var messageHandlerMock = new Mock <HttpMessageHandler>() .SetupSendAsyncMethod(HttpStatusCode.Unauthorized, "{}"); using (var httpClient = new HttpClient(messageHandlerMock.Object)) { var licenseOverviewService = new LicenseOverviewService(httpClient, _standardTokenProviderMock.Object); Func <Task <SubscriptionOverview> > action = () => licenseOverviewService.GetSubscriptionsAsync(CancellationToken.None); await action.Should().ThrowAsync <HttpRequestException>(); } }
public async Task GetSubscriptionsAsync_ReturnsMockedSubscriptions() { var messageHandlerMock = new Mock <HttpMessageHandler>() .SetupSendAsyncMethod(HttpStatusCode.OK, TestSubscriptions); using (var httpClient = new HttpClient(messageHandlerMock.Object)) { var licenseOverviewService = new LicenseOverviewService(httpClient, _standardTokenProviderMock.Object); var mockedSubscriptionOverview = await licenseOverviewService.GetSubscriptionsAsync(CancellationToken.None); mockedSubscriptionOverview.Should().BeOfType(typeof(SubscriptionOverview)); mockedSubscriptionOverview.Should().BeEquivalentTo(_expectedSubscriptions); messageHandlerMock.VerifySendAsyncWasInvokedExactlyOnce(); } }