public async Task Then_an_error_is_displayed_when_the_uln_has_already_been_submitted() { // Arrange var claims = new Claim[] { new Claim(EmployerClaimTypes.EmailAddress, _emailAddress), new Claim(EmployerClaimTypes.GivenName, _givenName), new Claim(EmployerClaimTypes.FamilyName, _familyName) }; var identity = new ClaimsIdentity(claims); var user = new ClaimsPrincipal(identity); _applicationService.Setup(x => x.Confirm(_accountId, _applicationId, _emailAddress, _userName)).ThrowsAsync(new UlnAlreadySubmittedException()); _applicationService.Setup(x => x.Get(_accountId, _applicationId, false, true)).ReturnsAsync(_fixture.Create <ApplicationModel>()); _sut = new Web.Controllers.ApplyController(_configuration.Object, _applicationService.Object, _legalEntitiesService.Object) { ControllerContext = new ControllerContext() }; _sut.ControllerContext.HttpContext = new DefaultHttpContext { User = user }; // Act var redirectResult = await _sut.SubmitApplication(_accountId, _applicationId) as RedirectToActionResult; // Assert redirectResult.Should().NotBeNull(); redirectResult.ActionName.Should().Be("UlnAlreadyAppliedFor"); _applicationService.Verify(x => x.Confirm(_accountId, _applicationId, _emailAddress, _userName), Times.Once); }
public async Task Then_the_application_is_submitted() { // Arrange var claims = new Claim[] { new Claim(EmployerClaimTypes.EmailAddress, _emailAddress), new Claim(EmployerClaimTypes.GivenName, _givenName), new Claim(EmployerClaimTypes.FamilyName, _familyName) }; var identity = new ClaimsIdentity(claims); var user = new ClaimsPrincipal(identity); _applicationService.Setup(x => x.Confirm(_accountId, _applicationId, _emailAddress, _userName)).Returns(Task.CompletedTask); _sut = new Web.Controllers.ApplyController(_configuration.Object, _applicationService.Object, _legalEntitiesService.Object) { ControllerContext = new ControllerContext() }; _sut.ControllerContext.HttpContext = new DefaultHttpContext { User = user }; // Act var redirectResult = await _sut.SubmitApplication(_accountId, _applicationId) as RedirectToActionResult; // Assert redirectResult.Should().NotBeNull(); redirectResult.ActionName.Should().Be("BankDetailsConfirmation"); redirectResult.ControllerName.Should().Be("BankDetails"); _applicationService.Verify(x => x.Confirm(_accountId, _applicationId, _emailAddress, _userName), Times.Once); }
public void Arrange() { _configuration = new Mock <IOptions <ExternalLinksConfiguration> >(); _applicationService = new Mock <IApplicationService>(); _legalEntitiesService = new Mock <ILegalEntitiesService>(); _fixture = new Fixture(); _accountId = _fixture.Create <string>(); _applicationId = Guid.NewGuid(); _sut = new Web.Controllers.ApplyController(_configuration.Object, _applicationService.Object, _legalEntitiesService.Object); }
public void Arrange() { _fixture = new Fixture(); _configuration = new Mock <IOptions <ExternalLinksConfiguration> >(); _externalLinksConfiguration = new ExternalLinksConfiguration { ManageApprenticeshipSiteUrl = _fixture.Create <string>() }; _configuration.Setup(x => x.Value).Returns(_externalLinksConfiguration); _applicationService = new Mock <IApplicationService>(); _legalEntitiesService = new Mock <ILegalEntitiesService>(); _accountId = _fixture.Create <string>(); _applicationId = Guid.NewGuid(); _sut = new Web.Controllers.ApplyController(_configuration.Object, _applicationService.Object, _legalEntitiesService.Object); }