public void post_legal_name_clarification_happy_path() { var applicationId = Guid.NewGuid(); var pageId = "1-10"; var vm = new LegalNamePageViewModel { Status = SectionReviewStatus.Pass, SourcesCheckedOn = DateTime.Now, ErrorMessages = new List <ValidationErrorDetail>(), ClarificationAnswer = ClarificationAnswer }; vm.SourcesCheckedOn = DateTime.Now; var command = new SubmitGatewayPageAnswerCommand(vm); var pageData = JsonConvert.SerializeObject(vm); GatewayValidator.Setup(v => v.ValidateClarification(command)).ReturnsAsync(new ValidationResponse { Errors = new List <ValidationErrorDetail>() }); ApplyApiClient.Setup(x => x.SubmitGatewayPageAnswer(applicationId, pageId, vm.Status, UserId, Username, It.IsAny <string>())); var result = _controller.ClarifyIcoNumberPage(command).Result; ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswerPostClarification(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), ClarificationAnswer), Times.Once); _orchestrator.Verify(x => x.GetLegalNameViewModel(It.IsAny <GetLegalNameRequest>()), Times.Never()); }
public void post_legal_name_clarification_path_with_errors() { var applicationId = Guid.NewGuid(); var pageId = "1-20"; var vm = new LegalNamePageViewModel { Status = SectionReviewStatus.Fail, SourcesCheckedOn = DateTime.Now, ErrorMessages = new List <ValidationErrorDetail>(), ClarificationAnswer = ClarificationAnswer }; vm.ApplicationId = applicationId; vm.PageId = vm.PageId; vm.SourcesCheckedOn = DateTime.Now; var command = new SubmitGatewayPageAnswerCommand(vm); GatewayValidator.Setup(v => v.ValidateClarification(command)) .ReturnsAsync(new ValidationResponse { Errors = new List <ValidationErrorDetail> { new ValidationErrorDetail { Field = "OptionFail", ErrorMessage = "needs text" } } } ); _orchestrator.Setup(x => x.GetLegalNameViewModel(It.Is <GetLegalNameRequest>(y => y.ApplicationId == vm.ApplicationId && y.UserName == Username))).ReturnsAsync(vm); var pageData = JsonConvert.SerializeObject(vm); GatewayValidator.Setup(v => v.ValidateClarification(command)) .ReturnsAsync(new ValidationResponse { Errors = new List <ValidationErrorDetail> { new ValidationErrorDetail { Field = "OptionFail", ErrorMessage = "needs text" } } } ); ApplyApiClient.Setup(x => x.SubmitGatewayPageAnswer(applicationId, pageId, vm.Status, UserId, Username, It.IsAny <string>())); var result = _controller.ClarifyLegalNamePage(command).Result; ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswer(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public async Task <LegalNamePageViewModel> GetLegalNameViewModel(GetLegalNameRequest request) { _logger.LogInformation($"Retrieving legal name details for application {request.ApplicationId}"); var model = new LegalNamePageViewModel(); await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.OrganisationChecks, GatewayPageIds.LegalName, request.UserId, request.UserName, RoatpGatewayConstants.Captions.OrganisationChecks, RoatpGatewayConstants.Headings.LegalName, NoSelectionErrorMessages.Errors[GatewayPageIds.LegalName]); var ukrlpDetails = await _applyApiClient.GetUkrlpDetails(request.ApplicationId); if (ukrlpDetails != null) { model.UkrlpLegalName = ukrlpDetails.ProviderName; if (ukrlpDetails.VerifiedByCompaniesHouse) { var companiesHouseDetails = await _applyApiClient.GetCompaniesHouseDetails(request.ApplicationId); if (companiesHouseDetails != null) { model.CompaniesHouseLegalName = companiesHouseDetails.CompanyName; } } if (ukrlpDetails.VerifiedbyCharityCommission) { var charityCommissionDetails = await _applyApiClient.GetCharityCommissionDetails(request.ApplicationId); if (charityCommissionDetails != null) { model.CharityCommissionLegalName = charityCommissionDetails.CharityName; } } } return(model); }