Exemple #1
0
        public void post_organisation_status_clarification_happy_path()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = "1-30";

            var viewModel = new OrganisationStatusViewModel()
            {
                Status              = SectionReviewStatus.Pass,
                SourcesCheckedOn    = DateTime.Now,
                ErrorMessages       = new List <ValidationErrorDetail>(),
                ClarificationAnswer = ClarificationAnswer
            };

            viewModel.SourcesCheckedOn = DateTime.Now;
            var command = new SubmitGatewayPageAnswerCommand(viewModel);

            GatewayValidator.Setup(v => v.ValidateClarification(command)).ReturnsAsync(new ValidationResponse {
                Errors = new List <ValidationErrorDetail>()
            });

            ApplyApiClient.Setup(x =>
                                 x.SubmitGatewayPageAnswer(applicationId, pageId, viewModel.Status, UserId, Username, It.IsAny <string>()));

            var result = _controller.ClarifyOrganisationStatus(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.GetOrganisationStatusViewModel(It.IsAny <GetOrganisationStatusRequest>()), Times.Never());
        }
        public async Task <OrganisationStatusViewModel> GetOrganisationStatusViewModel(GetOrganisationStatusRequest request)
        {
            _logger.LogInformation($"Retrieving organisation status details for application {request.ApplicationId}");

            var model = new OrganisationStatusViewModel();
            await model.PopulatePageCommonDetails(_applyApiClient, request.ApplicationId, GatewaySequences.OrganisationChecks,
                                                  GatewayPageIds.OrganisationStatus,
                                                  request.UserId,
                                                  request.UserName,
                                                  RoatpGatewayConstants.Captions.OrganisationChecks,
                                                  RoatpGatewayConstants.Headings.OrganisationStatusCheck,
                                                  NoSelectionErrorMessages.Errors[GatewayPageIds.OrganisationStatus]);

            var ukrlpDetails = await _applyApiClient.GetUkrlpDetails(request.ApplicationId);

            if (ukrlpDetails != null)
            {
                model.UkrlpStatus = ukrlpDetails.ProviderStatus?.CapitaliseFirstLetter();

                if (ukrlpDetails.VerifiedByCompaniesHouse)
                {
                    var companiesHouseDetails = await _applyApiClient.GetCompaniesHouseDetails(request.ApplicationId);

                    if (companiesHouseDetails != null)
                    {
                        model.CompaniesHouseStatus = companiesHouseDetails.Status.CapitaliseFirstLetter();
                    }
                }

                if (ukrlpDetails.VerifiedbyCharityCommission)
                {
                    var charityCommissionDetails = await _applyApiClient.GetCharityCommissionDetails(request.ApplicationId);

                    if (charityCommissionDetails != null)
                    {
                        model.CharityCommissionStatus = charityCommissionDetails.Status.CapitaliseFirstLetter();
                    }
                }
            }

            return(model);
        }
Exemple #3
0
        public void post_organisation_status_clarification_path_with_errors()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = "1-20";

            var viewModel = new OrganisationStatusViewModel()
            {
                Status              = SectionReviewStatus.Fail,
                SourcesCheckedOn    = DateTime.Now,
                ErrorMessages       = new List <ValidationErrorDetail>(),
                ClarificationAnswer = ClarificationAnswer
            };

            viewModel.ApplicationId    = applicationId;
            viewModel.PageId           = viewModel.PageId;
            viewModel.SourcesCheckedOn = DateTime.Now;
            var command = new SubmitGatewayPageAnswerCommand(viewModel);

            GatewayValidator.Setup(v => v.ValidateClarification(command))
            .ReturnsAsync(new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>
                {
                    new ValidationErrorDetail {
                        Field = "OptionFail", ErrorMessage = "needs text"
                    }
                }
            }
                          );

            _orchestrator.Setup(x => x.GetOrganisationStatusViewModel(It.IsAny <GetOrganisationStatusRequest>()))
            .ReturnsAsync(viewModel)
            .Verifiable("view model not returned");

            ApplyApiClient.Setup(x =>
                                 x.SubmitGatewayPageAnswer(applicationId, pageId, viewModel.Status, UserId, Username, It.IsAny <string>()));

            var result = _controller.ClarifyOrganisationStatus(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);
            _orchestrator.Verify(x => x.GetTradingNameViewModel(It.IsAny <GetTradingNameRequest>()), Times.Never());
        }