コード例 #1
0
        public void Setup()
        {
            _expectedData = new SearchPensionRegulatorResultsViewModel {
                Results = new List <PensionRegulatorDetailsViewModel> {
                    new PensionRegulatorDetailsViewModel(), new PensionRegulatorDetailsViewModel()
                }
            };

            var orchestrator = new Mock <SearchPensionRegulatorOrchestrator>();
            var owinWrapper  = new Mock <IAuthenticationService>();

            owinWrapper.Setup(x => x.GetClaimValue(ControllerConstants.UserRefClaimKeyName)).Returns(_expectedId);

            orchestrator
            .Setup(x => x.GetOrganisationsByAorn(ExpectedAorn, ExpectedPayeRef))
            .ReturnsAsync(
                new OrchestratorResponse <SearchPensionRegulatorResultsViewModel>
            {
                Data = _expectedData
            });

            orchestrator.Setup(x => x.GetCookieData())
            .Returns(
                new EmployerAccountData
            {
                EmployerAccountPayeRefData = new EmployerAccountPayeRefData
                {
                    PayeReference = "000/1234567"
                }
            });

            _mediator = new Mock <IMediator>();
            _mediator.Setup(x => x.SendAsync(new UpdateUserAornLockRequest()));
            _mediator.Setup(x => x.SendAsync(It.IsAny <GetPayeSchemeInUseQuery>())).ReturnsAsync(new GetPayeSchemeInUseResponse());
            _controller = new SearchPensionRegulatorController(
                owinWrapper.Object,
                orchestrator.Object,
                Mock.Of <IMultiVariantTestingService>(),
                Mock.Of <ICookieStorageService <FlashMessageViewModel> >(),
                _mediator.Object,
                Mock.Of <ICookieStorageService <HashedAccountIdModel> >());
        }
コード例 #2
0
        public void ThenThePensionRegulatorResultsPageIsDisplayed()
        {
            var viewModel = new SearchPensionRegulatorResultsViewModel
            {
                Results = new List <PensionRegulatorDetailsViewModel>
                {
                    new PensionRegulatorDetailsViewModel {
                        ReferenceNumber = 1
                    },
                    new PensionRegulatorDetailsViewModel {
                        ReferenceNumber = 2
                    }
                }
            };

            var response     = _controller.SearchPensionRegulator(It.IsAny <string>(), viewModel).Result;
            var viewResponse = (ViewResult)response;

            Assert.AreEqual(ControllerConstants.SearchPensionRegulatorResultsViewName, viewResponse.ViewName);
            Assert.AreEqual(true, viewResponse.ViewBag.InError);
        }
        public void ThenTheCheckYourDetailsPageIsDisplayed()
        {
            var viewModel = new SearchPensionRegulatorResultsViewModel
            {
                Results = new List <PensionRegulatorDetailsViewModel>
                {
                    new PensionRegulatorDetailsViewModel {
                        ReferenceNumber = 1
                    },
                    new PensionRegulatorDetailsViewModel {
                        ReferenceNumber = 2
                    }
                },
                SelectedOrganisation = 2
            };

            var response         = _controller.SearchPensionRegulator(It.IsAny <string>(), viewModel).Result;
            var redirectResponse = (RedirectToRouteResult)response;

            Assert.AreEqual(ControllerConstants.SummaryActionName, redirectResponse.RouteValues["action"].ToString());
            Assert.AreEqual(ControllerConstants.EmployerAccountControllerName, redirectResponse.RouteValues["controller"].ToString());
        }
コード例 #4
0
        public async Task <ActionResult> SearchPensionRegulator(string hashedAccountId, SearchPensionRegulatorResultsViewModel viewModel)
        {
            if (!viewModel.SelectedOrganisation.HasValue)
            {
                ViewBag.InError = true;
                return(View(ControllerConstants.SearchPensionRegulatorResultsViewName, viewModel));
            }

            if (viewModel.SelectedOrganisation == OrgNotListed)
            {
                return(RedirectToAction(ControllerConstants.SearchForOrganisationActionName, ControllerConstants.SearchOrganisationControllerName));
            }

            var item = viewModel.Results.SingleOrDefault(m => m.ReferenceNumber == viewModel.SelectedOrganisation);

            if (item == null)
            {
                return(View(ControllerConstants.SearchPensionRegulatorResultsViewName, viewModel));
            }

            await SavePensionRegulatorOrganisationDataIfItHasAValidName(item, true, true);

            return(RedirectToAction(ControllerConstants.SummaryActionName, ControllerConstants.EmployerAccountControllerName));
        }