public async Task saving_office_for_students_saves_evaluation_result()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = GatewayPageIds.OfficeForStudents;

            var vm = new OfficeForStudentsViewModel
            {
                ApplicationId    = applicationId,
                PageId           = pageId,
                Status           = SectionReviewStatus.Pass,
                SourcesCheckedOn = DateTime.Now,
                ErrorMessages    = new List <ValidationErrorDetail>(),
                OptionPassText   = "Some pass text"
            };

            var command = new SubmitGatewayPageAnswerCommand(vm);

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

            await _controller.EvaluateOfficeForStudentsPage(command);

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswer(applicationId, pageId, vm.Status, UserId, Username, vm.OptionPassText, null));
        }
        public async Task ConfirmRemoveApplication_When_oversight_performed_selected_returns_to_ViewApplication()
        {
            var applicationId = Guid.NewGuid();

            var viewModel = new RoatpRemoveApplicationViewModel
            {
                ApplicationId            = applicationId,
                ConfirmApplicationAction = HtmlAndCssElements.RadioButtonValueNo
            };

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(new Apply {
                ApplicationId = applicationId
            });
            ApplyApiClient.Setup(x => x.GetOversightDetails(applicationId)).ReturnsAsync(() =>
                                                                                         new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.Successful
            });
            _removeApplicationValidator.Setup(v => v.Validate(viewModel)).ReturnsAsync(new ValidationResponse {
                Errors = new List <ValidationErrorDetail>()
            });

            var result = await _controller.ConfirmRemoveApplication(applicationId, viewModel);

            var viewResult = result as RedirectToActionResult;

            Assert.AreEqual(nameof(RoatpGatewayController.ViewApplication), viewResult.ActionName);
            Assert.AreEqual("RoatpGateway", viewResult.ControllerName);
        }
        public async Task saving_office_for_students_without_required_fields_does_not_save()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = GatewayPageIds.OfficeForStudents;

            var vm = new OfficeForStudentsViewModel
            {
                Status           = SectionReviewStatus.Fail,
                SourcesCheckedOn = DateTime.Now,
                ErrorMessages    = new List <ValidationErrorDetail>(),
                ApplicationId    = applicationId,
                PageId           = pageId
            };

            var command = new SubmitGatewayPageAnswerCommand(vm);

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

            _orchestrator.Setup(x => x.GetOfficeForStudentsViewModel(It.Is <GetOfficeForStudentsRequest>(y => y.ApplicationId == vm.ApplicationId &&
                                                                                                         y.UserName == Username))).ReturnsAsync(vm);

            await _controller.EvaluateOfficeForStudentsPage(command);

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswer(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), null), Times.Never);
        }
        public async Task ConfirmWithdrawApplication_Yes_selected_And_fails_validation_returns_back_to_View()
        {
            var applicationId = Guid.NewGuid();

            var viewModel = new RoatpWithdrawApplicationViewModel
            {
                ApplicationId            = applicationId,
                ConfirmApplicationAction = HtmlAndCssElements.RadioButtonValueYes
            };

            var validationErrors = new List <ValidationErrorDetail> {
                new ValidationErrorDetail()
            };

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(new Apply {
                ApplicationId = applicationId
            });
            ApplyApiClient.Setup(x => x.GetOversightDetails(applicationId)).ReturnsAsync(() =>
                                                                                         new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.None
            });
            _withdrawApplicationValidator.Setup(v => v.Validate(viewModel)).ReturnsAsync(new ValidationResponse {
                Errors = validationErrors
            });

            var result = await _controller.ConfirmWithdrawApplication(applicationId, viewModel);

            var viewResult = result as ViewResult;

            Assert.IsTrue(viewResult.ViewName.EndsWith("ConfirmWithdrawApplication.cshtml"));
        }
        public async Task saving_initial_teacher_training_saves_clarification_result()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = GatewayPageIds.InitialTeacherTraining;

            var vm = new InitialTeacherTrainingViewModel
            {
                ApplicationId       = applicationId,
                PageId              = pageId,
                Status              = SectionReviewStatus.Pass,
                SourcesCheckedOn    = DateTime.Now,
                ErrorMessages       = new List <ValidationErrorDetail>(),
                OptionPassText      = "Some pass text",
                ClarificationAnswer = ClarificationAnswer
            };

            var command = new SubmitGatewayPageAnswerCommand(vm);

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

            await _controller.ClarifyInitialTeacherTrainingPage(command);

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswerPostClarification(applicationId, pageId, vm.Status, UserId, Username, vm.OptionPassText, ClarificationAnswer));
        }
Пример #6
0
        public void Organisation_criminal_compliance_check_result_is_saved(string gatewayPageId, string clarificationAnswer)
        {
            var model = new CriminalCompliancePageViewModel
            {
                ApplicationId             = Guid.NewGuid(),
                ApplyLegalName            = "legal name",
                ComplianceCheckQuestionId = "CC-20",
                ComplianceCheckAnswer     = "No",
                OptionPassText            = "check passed",
                Status              = "Pass",
                PageId              = gatewayPageId,
                QuestionText        = "Question text",
                Ukprn               = "10001234",
                ClarificationAnswer = clarificationAnswer
            };

            var validationResponse = new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>()
            };

            var command = new SubmitGatewayPageAnswerCommand(model);

            GatewayValidator.Setup(x => x.Validate(command)).ReturnsAsync(validationResponse);

            var result = _controller.EvaluateCriminalCompliancePage(command).GetAwaiter().GetResult();

            var redirectResult = result as RedirectToActionResult;

            redirectResult.Should().NotBeNull();
            redirectResult.ActionName.Should().Be("ViewApplication");

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswer(model.ApplicationId, gatewayPageId, model.Status, UserId, Username, model.OptionPassText, clarificationAnswer), Times.Once);
        }
        public async Task ConfirmWithdrawApplication_When_already_withdrawn_returns_to_ViewApplication(string oversightStatus)
        {
            var applicationId = Guid.NewGuid();

            var viewModel = new RoatpWithdrawApplicationViewModel
            {
                ApplicationId            = applicationId,
                ConfirmApplicationAction = HtmlAndCssElements.RadioButtonValueNo,
                ErrorMessages            = new List <ValidationErrorDetail>()
            };

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(new Apply {
                ApplicationId = applicationId, ApplicationStatus = ApplicationStatus.Withdrawn
            });
            _withdrawApplicationValidator.Setup(v => v.Validate(viewModel)).ReturnsAsync(new ValidationResponse {
                Errors = new List <ValidationErrorDetail>()
            });

            var result = await _controller.ConfirmWithdrawApplication(applicationId, viewModel);

            var viewResult = result as RedirectToActionResult;

            Assert.AreEqual(nameof(RoatpGatewayController.ViewApplication), viewResult.ActionName);
            Assert.AreEqual("RoatpGateway", viewResult.ControllerName);
        }
Пример #8
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());
        }
Пример #9
0
        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());
        }
Пример #10
0
        public void post_address_happy_path()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = "Address";

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

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

            var pageData = JsonConvert.SerializeObject(vm);

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

            var result = _controller.EvaluateAddressPage(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>(), null), Times.Once);
            _orchestrator.Verify(x => x.GetAddressViewModel(It.IsAny <GetAddressRequest>()), Times.Never());
        }
        public void post_website_address_clarification_happy_path()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = GatewayPageIds.WebsiteAddress;

            var vm = new WebsiteViewModel
            {
                ApplicationId       = applicationId,
                Status              = SectionReviewStatus.Pass,
                SourcesCheckedOn    = DateTime.Now,
                ErrorMessages       = new List <ValidationErrorDetail>(),
                OptionPassText      = comment,
                PageId              = pageId,
                ClarificationAnswer = ClarificationAnswer
            };
            var command = new SubmitGatewayPageAnswerCommand(vm);

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

            var result = _controller.ClarifyWebsitePage(command).Result;

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswerPostClarification(applicationId, pageId, vm.Status, UserId, Username, comment, ClarificationAnswer));
            _orchestrator.Verify(x => x.GetWebsiteViewModel(new GetWebsiteRequest(applicationId, UserId, Username)), Times.Never());
        }
        public async Task clarifying_initial_teacher_training_without_required_fields_does_not_save()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = GatewayPageIds.InitialTeacherTraining;

            var vm = new InitialTeacherTrainingViewModel()
            {
                Status              = SectionReviewStatus.Fail,
                SourcesCheckedOn    = DateTime.Now,
                ErrorMessages       = new List <ValidationErrorDetail>(),
                ApplicationId       = applicationId,
                PageId              = pageId,
                ClarificationAnswer = ClarificationAnswer
            };

            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.GetInitialTeacherTrainingViewModel(It.Is <GetInitialTeacherTrainingRequest>(y => y.ApplicationId == vm.ApplicationId &&
                                                                                                                   y.UserName == Username))).ReturnsAsync(vm);

            await _controller.ClarifyInitialTeacherTrainingPage(command);

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswer(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), ClarificationAnswer), Times.Never);
        }
        public void post_website_address_clarification_path_with_errors()
        {
            var applicationId = Guid.NewGuid();

            var vm = new WebsiteViewModel
            {
                ApplicationId       = applicationId,
                Status              = SectionReviewStatus.Fail,
                SourcesCheckedOn    = DateTime.Now,
                ErrorMessages       = new List <ValidationErrorDetail>(),
                ClarificationAnswer = ClarificationAnswer
            };

            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.GetWebsiteViewModel(It.Is <GetWebsiteRequest>(y => y.ApplicationId == vm.ApplicationId &&
                                                                                     y.UserName == Username))).ReturnsAsync(vm);

            var result = _controller.ClarifyWebsitePage(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);
        }
Пример #14
0
        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 ConfirmOutcome_evaluation_result_is_on_error()
        {
            var applicationId = Guid.NewGuid();

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(new Apply {
                ApplicationId = applicationId, ApplyData = new ApplyData {
                    ApplyDetails = new ApplyDetails {
                    }
                }
            });

            var viewModel = new RoatpGatewayApplicationViewModel
            {
                ApplicationId       = applicationId,
                GatewayReviewStatus = GatewayReviewStatus.InProgress,
                ErrorMessages       = new List <ValidationErrorDetail>()
            };

            _validator.Setup(v => v.Validate(viewModel))
            .ReturnsAsync(new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>
                {
                    new ValidationErrorDetail {
                        Field = "GatewayReviewStatus", ErrorMessage = "Select what you want to do"
                    }
                }
            });

            var expectedViewModelWithErrors = new RoatpGatewayApplicationViewModel
            {
                ApplicationId       = applicationId,
                GatewayReviewStatus = GatewayReviewStatus.New,
                ErrorMessages       = new List <ValidationErrorDetail>
                {
                    new ValidationErrorDetail {
                        Field = "GatewayReviewStatus", ErrorMessage = "Select what you want to do"
                    }
                }
            };

            _orchestrator.Setup(x => x.GetConfirmOverviewViewModel(It.Is <GetApplicationOverviewRequest>(y => y.ApplicationId == applicationId && y.UserName == Username))).ReturnsAsync(expectedViewModelWithErrors);

            var result = await _controller.EvaluateConfirmOutcome(viewModel);

            var viewResult = result as ViewResult;

            Assert.AreSame(expectedViewModelWithErrors, viewResult.Model);
        }
        public void PeopleInControl_criminal_compliance_clarification_check_has_validation_error(string gatewayPageId)
        {
            var clarificationAnswer = "clarification answer";
            var model = new CriminalCompliancePageViewModel
            {
                ApplicationId             = Guid.NewGuid(),
                ApplyLegalName            = "legal name",
                ComplianceCheckQuestionId = "CC-40",
                ComplianceCheckAnswer     = "No",
                OptionFailText            = null,
                Status              = "Fail",
                PageId              = gatewayPageId,
                QuestionText        = "Question text",
                Ukprn               = "10001234",
                ClarificationAnswer = clarificationAnswer
            };

            var validationResponse = new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>()
                {
                    new ValidationErrorDetail
                    {
                        ErrorMessage = "Comments are mandatory",
                        Field        = "OptionFailText"
                    }
                }
            };

            var command = new SubmitGatewayPageAnswerCommand(model);

            GatewayValidator.Setup(x => x.ValidateClarification(command)).ReturnsAsync(validationResponse);

            _orchestrator.Setup(x => x.GetCriminalComplianceCheckViewModel(It.Is <GetCriminalComplianceCheckRequest>(y => y.ApplicationId == model.ApplicationId &&
                                                                                                                     y.UserName == Username))).ReturnsAsync(model);

            var result = _controller.ClarifyCriminalCompliancePage(command).GetAwaiter().GetResult();

            var viewResult = result as ViewResult;
            var viewModel  = viewResult.Model as CriminalCompliancePageViewModel;

            viewModel.Should().NotBeNull();
            viewModel.ErrorMessages.Count.Should().BeGreaterThan(0);

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswer(model.ApplicationId, gatewayPageId, model.Status, UserId, Username, model.OptionPassText, clarificationAnswer), Times.Never);
        }
        public async Task AboutToAskForClarification_with_yes_then_redirected_to_successful_page()
        {
            var applicationId = Guid.NewGuid();

            _orchestrator.Setup(x => x.GetClarificationViewModel(It.IsAny <GetApplicationClarificationsRequest>()))
            .ReturnsAsync(new RoatpGatewayClarificationsViewModel());

            ApplyApiClient.Setup(x => x.UpdateGatewayReviewStatusAsClarification(applicationId, It.IsAny <string>(), It.IsAny <string>()));

            var confirmAskForClarification = "Yes";
            var result = await _controller.AboutToAskForClarification(applicationId, confirmAskForClarification);

            var viewResult = result as ViewResult;

            Assert.IsTrue(viewResult.ViewName.Contains("ConfirmApplicationClarification.cshtml"));
            ApplyApiClient.Verify(x => x.UpdateGatewayReviewStatusAsClarification(applicationId, It.IsAny <string>(), It.IsAny <string>()), Times.Once);
        }
        public async Task ConfirmOutcome_model_is_returned()
        {
            var applicationId     = Guid.NewGuid();
            var expectedViewModel = new RoatpGatewayApplicationViewModel {
                ReadyToConfirm = true
            };

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(new Apply {
                ApplicationId = applicationId
            });
            _orchestrator.Setup(x => x.GetConfirmOverviewViewModel(It.Is <GetApplicationOverviewRequest>(y => y.ApplicationId == applicationId && y.UserName == Username))).ReturnsAsync(expectedViewModel);

            var result = await _controller.ConfirmOutcome(applicationId, GatewayReviewStatus.Pass, null, null, 0);

            var viewResult = result as ViewResult;

            Assert.AreSame(expectedViewModel, viewResult.Model);
        }
        public async Task AboutToRejectOutcome_selection_No()
        {
            var applicationId      = Guid.NewGuid();
            var expectedActionName = "ConfirmOutcome";
            var viewModel          = new RoatpGatewayRejectedOutcomeViewModel
            {
                ApplicationId         = applicationId,
                GatewayReviewStatus   = GatewayReviewStatus.Rejected,
                GatewayReviewComment  = "some comment",
                ConfirmGatewayOutcome = "No"
            };

            var result = await _controller.AboutToRejectOutcome(viewModel);

            var redirectToActionResult = result as RedirectToActionResult;

            Assert.AreSame(expectedActionName, redirectToActionResult.ActionName);
            ApplyApiClient.Verify(x => x.UpdateGatewayReviewStatusAndComment(applicationId, viewModel.GatewayReviewStatus, viewModel.GatewayReviewComment, viewModel.GatewayReviewExternalComment, viewModel.SubcontractingLimit, UserId, Username), Times.Never);
        }
        public async Task AboutToRejectOutcome_selection_Yes()
        {
            var applicationId = Guid.NewGuid();
            var viewModel     = new RoatpGatewayRejectedOutcomeViewModel
            {
                ApplicationId         = applicationId,
                GatewayReviewStatus   = GatewayReviewStatus.Rejected,
                GatewayReviewComment  = "some comment",
                ConfirmGatewayOutcome = "Yes"
            };

            var result = await _controller.AboutToRejectOutcome(viewModel);

            var viewResult      = result as ViewResult;
            var viewResultModel = viewResult.Model as RoatpGatewayOutcomeViewModel;

            Assert.AreSame(viewModel.GatewayReviewStatus, viewResultModel.GatewayReviewStatus);
            ApplyApiClient.Verify(x => x.UpdateGatewayReviewStatusAndComment(applicationId, viewModel.GatewayReviewStatus, viewModel.GatewayReviewComment, viewModel.GatewayReviewExternalComment, viewModel.SubcontractingLimit, UserId, Username), Times.Once);
        }
Пример #21
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());
        }
        public async Task ClosedApplications_ViewModel_Has_Correct_Application_Counts()
        {
            ApplyApiClient.Setup(x => x.GetClosedGatewayApplications(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(new List <RoatpApplicationSummaryItem>());

            ApplyApiClient.Setup(x => x.GetApplicationCounts(It.IsAny <string>())).ReturnsAsync(new GetGatewayApplicationCountsResponse
            {
                NewApplicationsCount        = 1,
                InProgressApplicationsCount = 2,
                ClosedApplicationsCount     = 3
            });

            var result = await _controller.ClosedApplications(null, "", "", 1);

            var viewResult      = result as ViewResult;
            var resultViewModel = viewResult.Model as RoatpGatewayDashboardViewModel;

            Assert.AreEqual(1, resultViewModel.ApplicationCounts.NewApplicationsCount);
            Assert.AreEqual(2, resultViewModel.ApplicationCounts.InProgressApplicationsCount);
            Assert.AreEqual(3, resultViewModel.ApplicationCounts.ClosedApplicationsCount);
        }
        public async Task AboutToRejectOutcome_no_selection()
        {
            var applicationId = Guid.NewGuid();
            var viewModel     = new RoatpGatewayRejectedOutcomeViewModel
            {
                ApplicationId        = applicationId,
                GatewayReviewStatus  = GatewayReviewStatus.Rejected,
                GatewayReviewComment = "some comment"
            };

            _controller.ModelState.AddModelError("ConfirmGatewayOutcome", "Select if you are sure you want to reject this application");

            var result = await _controller.AboutToRejectOutcome(viewModel);

            var viewResult      = result as ViewResult;
            var resultViewModel = viewResult.Model as RoatpGatewayRejectedOutcomeViewModel;

            Assert.AreSame(HtmlAndCssElements.CssFormGroupErrorClass, resultViewModel.CssFormGroupError);
            ApplyApiClient.Verify(x => x.UpdateGatewayReviewStatusAndComment(applicationId, viewModel.GatewayReviewStatus, viewModel.GatewayReviewComment, viewModel.GatewayReviewExternalComment, viewModel.SubcontractingLimit, UserId, Username), Times.Never);
        }
        public void post_website_address_happy_path()
        {
            var applicationId = Guid.NewGuid();
            var pageId        = GatewayPageIds.WebsiteAddress;

            var vm = new WebsiteViewModel
            {
                ApplicationId    = applicationId,
                Status           = SectionReviewStatus.Pass,
                SourcesCheckedOn = DateTime.Now,
                ErrorMessages    = new List <ValidationErrorDetail>(),
                OptionPassText   = comment,
                PageId           = pageId
            };
            var command = new SubmitGatewayPageAnswerCommand(vm);

            var result = _controller.EvaluateWebsitePage(command).Result;

            ApplyApiClient.Verify(x => x.SubmitGatewayPageAnswer(applicationId, pageId, vm.Status, UserId, Username, comment, null));
            _orchestrator.Verify(x => x.GetWebsiteViewModel(new GetWebsiteRequest(applicationId, UserId, Username)), Times.Never());
        }
        public async Task ConfirmWithdrawApplication_Yes_selected_And_passed_validation_performs_Application_Withdrawal()
        {
            var applicationId = Guid.NewGuid();

            var application = new Apply
            {
                ApplicationId = applicationId,
                ApplyData     = new ApplyData {
                    ApplyDetails = new ApplyDetails()
                }
            };

            var viewModel = new RoatpWithdrawApplicationViewModel
            {
                ApplicationId            = applicationId,
                ConfirmApplicationAction = HtmlAndCssElements.RadioButtonValueYes,
                OptionYesText            = "Comments"
            };

            var validationErrors = new List <ValidationErrorDetail>();

            ApplyApiClient.Setup(x => x.GetApplication(applicationId)).ReturnsAsync(application);
            ApplyApiClient.Setup(x => x.GetOversightDetails(applicationId)).ReturnsAsync(() =>
                                                                                         new ApplicationOversightDetails {
                OversightStatus = OversightReviewStatus.None
            });
            _withdrawApplicationValidator.Setup(v => v.Validate(viewModel)).ReturnsAsync(new ValidationResponse {
                Errors = validationErrors
            });

            var result = await _controller.ConfirmWithdrawApplication(applicationId, viewModel);

            var viewResult = result as ViewResult;

            Assert.IsTrue(viewResult.ViewName.EndsWith("ApplicationWithdrawn.cshtml"));
            ApplyApiClient.Verify(x => x.WithdrawApplication(viewModel.ApplicationId, viewModel.OptionYesText, It.IsAny <string>(), It.IsAny <string>()), Times.Once);
        }