Exemple #1
0
        public async Task WhenBodyCalledWithInvalidPassword_ReturnToViewWithError()
        {
            var customer = new Customer
            {
                CustomerId = new Guid("c2e27821-cc60-4d3d-b4f0-cbe20867897c"),
                Contact    = new Contact
                {
                    EmailAddress = "user"
                }
            };

            _authService.GetCustomer(Arg.Any <ClaimsPrincipal>()).ReturnsForAnyArgs(customer);
            _openIdConnectClient.VerifyPassword("user", "password").ReturnsForAnyArgs(Result.Fail("Failed"));
            var controller = new CloseYourAccountController(_compositeSettings, _authService, _openIdConnectClient, _documentService, _config);
            var closeYourAccountCompositeViewModel = new CloseYourAccountCompositeViewModel();

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            var result = await controller.Body(closeYourAccountCompositeViewModel) as ViewResult;

            result.ViewData.ModelState.IsValid.Should().BeFalse();
            result.ViewData.ModelState["Password"].Errors[0].ErrorMessage.Should().Be("Wrong password. Try again.");
        }
Exemple #2
0
        public async Task WhenBodyCalled_ReturnHtml()
        {
            var customer = new Customer
            {
                CustomerId = new Guid("c2e27821-cc60-4d3d-b4f0-cbe20867897c"),
                Contact    = new Contact
                {
                    EmailAddress = "user"
                }
            };

            _authService.GetCustomer(Arg.Any <ClaimsPrincipal>()).ReturnsForAnyArgs(customer);
            var controller = new CloseYourAccountController(_compositeSettings, _authService, _openIdConnectClient, _documentService, _config);

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };

            var result = await controller.Body() as ViewResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <ViewResult>();

            result.ViewName.Should().BeNull();
        }
Exemple #3
0
        public async Task WhenBodyCalledWithInvalidModelState_ReturnToViewWithError()
        {
            var controller = new CloseYourAccountController(_compositeSettings, _authService, _openIdConnectClient, _documentService, _config);
            var closeYourAccountCompositeViewModel = new CloseYourAccountCompositeViewModel();

            controller.ControllerContext = new ControllerContext
            {
                HttpContext = new DefaultHttpContext()
            };
            controller.ModelState.AddModelError("password", "Invalid password");
            var result = await controller.Body(closeYourAccountCompositeViewModel) as ViewResult;

            result.ViewData.ModelState.IsValid.Should().BeFalse();
        }