public async Task ThenTheMediatorIsCalledToGetThePensionRegulatorResult() { //Arrange var payeRef = "123/4567"; //Act await _orchestrator.SearchPensionRegulator(payeRef); //Assert _mediator.Verify(x => x.SendAsync(It.Is <GetPensionRegulatorRequest>(c => c.PayeRef.Equals(payeRef))), Times.Once); }
public async Task <ActionResult> SearchPensionRegulator(string hashedAccountId) { var payeRef = _searchPensionRegulatorOrchestrator.GetCookieData().EmployerAccountPayeRefData.PayeReference; if (string.IsNullOrEmpty(payeRef)) { return(RedirectToAction(ControllerConstants.GatewayViewName, ControllerConstants.EmployerAccountControllerName)); } var model = await _searchPensionRegulatorOrchestrator.SearchPensionRegulator(payeRef); model.Data.IsExistingAccount = !string.IsNullOrEmpty(hashedAccountId); switch (model.Data.Results.Count) { case 0: { return(RedirectToAction(ControllerConstants.SearchForOrganisationActionName, ControllerConstants.SearchOrganisationControllerName)); } case 1: { await SavePensionRegulatorOrganisationDataIfItHasAValidName(model.Data.Results.First(), true, false); return(RedirectToAction(ControllerConstants.SummaryActionName, ControllerConstants.EmployerAccountControllerName)); } default: { return(View(ControllerConstants.SearchPensionRegulatorResultsViewName, model.Data)); } } }
public async Task ThenEachResultIsCorrectlyMarkedAsComingFromPensionsRegulator() { var actual = await _orchestrator.SearchPensionRegulator(It.IsAny <string>()); Assert .IsTrue( actual .Data .Results .All(organisation => organisation.Type == OrganisationType.PensionsRegulator)); }