public async Task When_UpdatingEpaRecord_CallsInternalApi_Then_ReturnEpaResponseWithResponseCode200( [Frozen] Mock <IHeaderInfo> headerInfo, [Frozen] Mock <IApiClient> apiClient, UpdateEpaRequest request, IEnumerable <UpdateEpaResponse> response, EpaController sut) { //Arrange apiClient.Setup(client => client.UpdateEpas(It.Is <IEnumerable <UpdateBatchEpaRequest> >(s => s.First().UkPrn == headerInfo.Object.Ukprn && s.First().EpaReference == request.EpaReference && s.First().RequestId == request.RequestId && s.First().Learner == request.Learner && s.First().LearningDetails == request.LearningDetails && s.First().Standard == request.Standard && s.First().EpaDetails == request.EpaDetails))).ReturnsAsync(response); //Act var result = await sut.UpdateEpaRecords(new List <UpdateEpaRequest> { request }) as ObjectResult; //Assert result.StatusCode.Should().Be((int)HttpStatusCode.OK); var model = result.Value as IEnumerable <UpdateEpaResponse>; model.Should().BeEquivalentTo(response); }
public async Task When_CreatingEpaRecord_WithTooManyRequestsInBatch_CallsInternalApi_Then_ReturnApiResponseWithResponseCode403( CreateEpaRequest request, EpaController sut) { //Arrange var requests = new List <CreateEpaRequest>(); for (var i = 0; i < 26; i++) { requests.Add(request); } //Act var result = await sut.CreateEpaRecords(requests) as ObjectResult; //Assert result.StatusCode.Should().Be((int)HttpStatusCode.Forbidden); ((ApiResponse)result.Value).Message.Should().Be("Batch limited to 25 requests"); }
public async Task When_DeletingEpaRecord_CallsInternalApi_AndItErrors_Then_ReturnErrorResponseCode( [Frozen] Mock <IHeaderInfo> headerInfo, [Frozen] Mock <IApiClient> apiClient, long uln, string familyName, string standard, string epaReference, EpaController sut) { //Arrange var response = new ApiResponse((int)HttpStatusCode.BadRequest); apiClient.Setup(client => client.DeleteEpa(It.Is <DeleteBatchEpaRequest>(s => s.UkPrn == headerInfo.Object.Ukprn && s.EpaReference == epaReference && s.Uln == uln && s.FamilyName == familyName && s.Standard == standard))).ReturnsAsync(response); //Act var result = await sut.DeleteEpaRecord(uln, familyName, standard, epaReference) as ObjectResult; //Assert result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); }