Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }