public void TestThat_ResetPassword_GeneratesAPasswordResetTokenForTheUser_WhenAValidUserIsFound_FromAUserName()
        {
            var userProfileRepository = Substitute.For<IUserProfileRepository>();
            userProfileRepository.GetUserProfileByUserName("bob").Returns(new UserProfile { UserName = "******", EmailAddress = "*****@*****.**" });
            var resetPasswordService = Substitute.For<IResetPasswordService>();
            var controller = new ResetPasswordController(userProfileRepository, resetPasswordService, new EmailMessengerFactory(Substitute.For<IPostman>()));
            controller.SetupWithHttpContextAndUrlHelper();

            var model = new ResetPasswordStepOneModel { UserName = "******" };
            controller.ResetPassword(model);

            resetPasswordService.Received().GeneratePasswordResetToken("bob", Arg.Any<int>());
        }
        public void TestThat_ResetPassword_SendsAnEmailToTheUser_WhenAValidUserIsFound_FromAUserName()
        {
            var userProfileRepository = Substitute.For<IUserProfileRepository>();
            var userProfile = new UserProfile { UserName = "******", EmailAddress = "*****@*****.**" };
            userProfileRepository.GetUserProfileByUserName("bob").Returns(userProfile);
            var postman = Substitute.For<IPostman>();
            var controller = new ResetPasswordController(userProfileRepository, Substitute.For<IResetPasswordService>(), new EmailMessengerFactory(postman));
            controller.SetupWithHttpContextAndUrlHelper();

            var model = new ResetPasswordStepOneModel { UserName = "******" };
            controller.ResetPassword(model);

            var expectedMessage = MailMessage.FromTemplate(PasswordResetMailTemplate.Create(string.Empty), userProfile);
            postman.Received().Deliver(expectedMessage);
        }