public void Handle_CallsApiClient_ReturnException( [Frozen] Mock <IRoatpCourseManagementApiClient <RoatpV2ApiConfiguration> > apiClientMock, UpdateStandardSubRegionsCommandHandler sut, UpdateStandardSubRegionsCommand command, CancellationToken cancellationToken, HttpRequestContentException expectedException) { apiClientMock.Setup(a => a.Get <List <ProviderLocationModel> >(It.IsAny <GetAllProviderLocationsQuery>())).Throws(expectedException); var actualException = Assert.ThrowsAsync <HttpRequestContentException>(() => sut.Handle(command, cancellationToken)); actualException.Should().Be(expectedException); }
public async Task Handle_CallsApiClient( [Frozen] Mock <IRoatpCourseManagementApiClient <RoatpV2ApiConfiguration> > apiClientMock, UpdateStandardSubRegionsCommandHandler sut, UpdateStandardSubRegionsCommand command, CancellationToken cancellationToken, List <ProviderLocationModel> apiResponse) { apiClientMock.Setup(a => a.Get <List <ProviderLocationModel> >(It.IsAny <GetAllProviderLocationsQuery>())).ReturnsAsync(apiResponse); var result = await sut.Handle(command, cancellationToken); apiClientMock.Verify(a => a.Get <List <ProviderLocationModel> >(It.IsAny <GetAllProviderLocationsQuery>()), Times.Once); apiClientMock.Verify(a => a.PostWithResponseCode <ProviderLocationsBulkInsertRequest>(It.IsAny <ProviderLocationsBulkInsertRequest>()), Times.Once); apiClientMock.Verify(a => a.Delete(It.IsAny <ProviderCourseLocationsBulkDeleteRequest>()), Times.Once); apiClientMock.Verify(a => a.PostWithResponseCode <ProviderCourseLocationBulkInsertRequest>(It.IsAny <ProviderCourseLocationBulkInsertRequest>()), Times.Once); apiClientMock.Verify(a => a.Delete(It.IsAny <ProviderLocationBulkDeleteRequest>()), Times.Once); Assert.IsNotNull(result); }