public async Task Recovery_post_should_return_RecoveryPasswordEmailSent_page_if_email_sent()
        {
            var data = Builder <RecoveryPasswordModel> .CreateNew()
                       .With(d => d.Username = "******")
                       .Build();

            var operationResult = Builder <OperationResult> .CreateNew()
                                  .With(o => o.Succeeded = true)
                                  .Build();

            _fakeContext.Setup(x => x.User.Identity.IsAuthenticated).Returns(false);

            var passwordMgntController = new PasswordManagementController(_mediator.Object);

            passwordMgntController.ControllerContext.HttpContext = _fakeContext.Object;

            _mediator.Setup(mediatr => mediatr.Send(It.IsAny <IdentityServer.Application.PasswordManagement.RecoveryPassword.Command>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(operationResult);

            var result = await passwordMgntController.RecoveryPassword(data);

            var viewResult = Assert.IsType <ViewResult>(result);

            viewResult.ViewName.Should().Be("RecoveryPasswordEmailSent");
        }
        public void Recovery_request_should_return_recovery_password_page_if_user_not_authenticated()
        {
            _fakeContext.Setup(x => x.User.Identity.IsAuthenticated).Returns(false);

            var passwordMgntController = new PasswordManagementController(_mediator.Object);

            passwordMgntController.ControllerContext.HttpContext = _fakeContext.Object;

            var result = passwordMgntController.RecoveryPassword();

            var viewResult = Assert.IsType <ViewResult>(result);

            viewResult.ViewName.Should().Be(nameof(passwordMgntController.RecoveryPassword));
        }
        public void Recovery_request_should_redirect_to_Login_if_user_authenticated()
        {
            _fakeContext.Setup(x => x.User.Identity.IsAuthenticated).Returns(true);

            var passwordMgntController = new PasswordManagementController(_mediator.Object);

            passwordMgntController.ControllerContext.HttpContext = _fakeContext.Object;

            var result = passwordMgntController.RecoveryPassword();

            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            redirectToActionResult.ActionName.Should().Be(nameof(AccountController.Login));
            redirectToActionResult.ControllerName.Should().Be("Account");
        }
        public async Task Recovery_post_should_redirect_to_Login_if_user_authenticated()
        {
            var data = Builder <RecoveryPasswordModel> .CreateNew()
                       .With(d => d.Username = "******")
                       .Build();

            _fakeContext.Setup(x => x.User.Identity.IsAuthenticated).Returns(true);

            var passwordMgntController = new PasswordManagementController(_mediator.Object);

            passwordMgntController.ControllerContext.HttpContext = _fakeContext.Object;

            var result = await passwordMgntController.RecoveryPassword(data);

            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            redirectToActionResult.ActionName.Should().Be(nameof(AccountController.Login));
            redirectToActionResult.ControllerName.Should().Be("Account");
        }