Пример #1
0
        protected async Task <IActionResult> ValidateAndUpdatePageAnswer <VM>(SubmitGatewayPageAnswerCommand command,
                                                                              Func <Task <VM> > viewModelBuilder,
                                                                              string errorView) where VM : RoatpGatewayPageViewModel
        {
            var validationResponse = await GatewayValidator.Validate(command);

            if (validationResponse.Errors != null && validationResponse.Errors.Any())
            {
                var viewModel = await viewModelBuilder.Invoke();

                viewModel.Status                  = command.Status;
                viewModel.OptionFailText          = command.OptionFailText;
                viewModel.OptionInProgressText    = command.OptionInProgressText;
                viewModel.OptionClarificationText = command.OptionClarificationText;
                viewModel.OptionPassText          = command.OptionPassText;
                viewModel.ErrorMessages           = validationResponse.Errors;
                return(View(errorView, viewModel));
            }

            if (command.Status == SectionReviewStatus.Clarification)
            {
                return(await SubmitGatewayPageAnswerClarification(command));
            }
            else
            {
                return(await SubmitGatewayPageAnswer(command));
            }
        }
        public void test_cases_for_no_status_and_no_fail_text_to_check_messages_as_expected(string status, string passMessage, string inProgressMessage, string failMessage, string clarificationMessage, bool hasErrorMessage)
        {
            _viewModel = new RoatpGatewayPageViewModel
            {
                Status                  = status,
                OptionPassText          = passMessage,
                OptionFailText          = failMessage,
                OptionInProgressText    = inProgressMessage,
                OptionClarificationText = clarificationMessage,
                PageId                  = GatewayPageIds.LegalName
            };

            var command = new SubmitGatewayPageAnswerCommand(_viewModel);

            var result = _validator.Validate(command).Result;

            Assert.AreEqual(hasErrorMessage, result.Errors.Any());
        }