/// <inheritdoc/> public async Task <RequestResult <ImmunizationResult> > GetImmunizations(string bearerToken, int pageIndex = 0) { RequestResult <PHSAResult <ImmunizationResponse> > delegateResult = await this.immunizationDelegate.GetImmunizations(bearerToken, pageIndex).ConfigureAwait(true); if (delegateResult.ResultStatus == ResultType.Success) { return(new RequestResult <ImmunizationResult>() { ResultStatus = delegateResult.ResultStatus, ResourcePayload = new ImmunizationResult() { LoadState = LoadStateModel.FromPHSAModel(delegateResult.ResourcePayload.LoadState), Immunizations = ImmunizationEvent.FromPHSAModelList(delegateResult.ResourcePayload.Result.ImmunizationViews), Recommendations = ImmunizationRecommendation.FromPHSAModelList(delegateResult.ResourcePayload.Result.Recommendations), }, PageIndex = delegateResult.PageIndex, PageSize = delegateResult.PageSize, TotalResultCount = delegateResult.TotalResultCount, }); } else { return(new RequestResult <ImmunizationResult>() { ResultStatus = delegateResult.ResultStatus, ResultError = delegateResult.ResultError, }); } }
public void ValidateImmunization() { var mockDelegate = new Mock <IImmunizationDelegate>(); RequestResult <PHSAResult <ImmunizationResponse> > delegateResult = new RequestResult <PHSAResult <ImmunizationResponse> >() { ResultStatus = Common.Constants.ResultType.Success, ResourcePayload = new PHSAResult <ImmunizationResponse>() { LoadState = new PHSALoadState() { RefreshInProgress = false, }, Result = new ImmunizationResponse() { ImmunizationViews = new List <ImmunizationViewResponse>() { new ImmunizationViewResponse() { Id = Guid.NewGuid(), Name = "MockImmunization", OccurrenceDateTime = DateTime.Now, SourceSystemId = "MockSourceID" } }, }, }, PageIndex = 0, PageSize = 5, TotalResultCount = 1, }; RequestResult <ImmunizationResult> expectedResult = new RequestResult <ImmunizationResult>() { ResultStatus = delegateResult.ResultStatus, ResourcePayload = new ImmunizationResult() { LoadState = LoadStateModel.FromPHSAModel(delegateResult.ResourcePayload.LoadState), Immunizations = ImmunizationEvent.FromPHSAModelList(delegateResult.ResourcePayload.Result.ImmunizationViews), }, PageIndex = delegateResult.PageIndex, PageSize = delegateResult.PageSize, TotalResultCount = delegateResult.TotalResultCount, }; mockDelegate.Setup(s => s.GetImmunizations(It.IsAny <string>(), It.IsAny <int>())).Returns(Task.FromResult(delegateResult)); IImmunizationService service = new ImmunizationService(new Mock <ILogger <ImmunizationService> >().Object, mockDelegate.Object); var actualResult = service.GetImmunizations(string.Empty, 0); Assert.True(expectedResult.IsDeepEqual(actualResult.Result)); }