public void When_forgot_password_with_incorrect_email()
        {
            var mockEmailManager = new Mock<EmailHelper>();
            mockEmailManager.Setup(x => x.SendForgotPasswordEmail(It.IsAny<UserInfo>(), It.IsAny<string>()))
                .Returns(true);


            var mockDatabaseAccess = new Mock<IUserRepository>();
            mockDatabaseAccess.Setup(x => x.GetUserByEmailAsync(It.IsAny<string>())).ThrowsAsync(new Exception());

            var forgotPasswordHelper = new ForgotPasswordHelper(mockDatabaseAccess.Object, mockEmailManager.Object);

            Assert.ThrowsAsync<Exception>(async () => await forgotPasswordHelper.SendEmail("*****@*****.**"));
        }
        public async Task <IActionResult> Post(string email)
        {
            try
            {
                var forgotPasswordHelper = new ForgotPasswordHelper();
                var result = await forgotPasswordHelper.SendEmail(email);

                if (result == false)
                {
                    return(StatusCode(500,
                                      "An error occurred while trying to send the password reset email. Please try again later."));
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest("User with that email does not exist."));
            }
        }
        public async Task When_forgot_password()
        {
            var mockDatabaseAccess = new Mock<IUserRepository>();
            mockDatabaseAccess.Setup(x => x.GetUserByEmailAsync(It.IsAny<string>())).ReturnsAsync(new UserInfo
            {
                Email = "*****@*****.**",
                Password = "******"
            });
            var mockEmailHelper = new Mock<EmailHelper>();
            mockEmailHelper.Setup(x => x.SendForgotPasswordEmail(It.IsAny<UserInfo>(), It.IsAny<string>()))
                .Returns(true);

            var forgotPasswordHelper =
                new ForgotPasswordHelper(mockDatabaseAccess.Object, mockEmailHelper.Object);

            var result = await forgotPasswordHelper.SendEmail("*****@*****.**");

            Assert.That(result, Is.True);
        }