public async Task Handle_CallsApiClient( [Frozen] Mock <IRoatpCourseManagementApiClient <RoatpV2ApiConfiguration> > apiClientMock, UpdateContactDetailsCommandHandler sut, UpdateContactDetailsCommand command, CancellationToken cancellationToken, ProviderCourseUpdateRequest request, GetProviderCourseResponse apiResponse) { apiClientMock.Setup(a => a.Get <GetProviderCourseResponse>(It.IsAny <GetProviderCourseRequest>())).ReturnsAsync(apiResponse); await sut.Handle(command, cancellationToken); apiClientMock.Verify(a => a.Put(It.IsAny <ProviderCourseUpdateRequest>()), Times.Once); }
public void Handle_CallsApiClient_ReturnException( [Frozen] Mock <IRoatpCourseManagementApiClient <RoatpV2ApiConfiguration> > apiClientMock, UpdateContactDetailsCommandHandler sut, UpdateContactDetailsCommand command, CancellationToken cancellationToken, GetProviderCourseResponse apiResponse, HttpRequestContentException expectedException) { apiClientMock.Setup(a => a.Get <GetProviderCourseResponse>(It.IsAny <GetProviderCourseRequest>())).ReturnsAsync(apiResponse); apiClientMock.Setup(c => c.Put(It.IsAny <ProviderCourseUpdateRequest>())).Throws(expectedException); var actualException = Assert.ThrowsAsync <HttpRequestContentException>(() => sut.Handle(command, cancellationToken)); actualException.Should().Be(expectedException); }