Esempio n. 1
0
        public async Task <IActionResult> Post(PasswordChangeHelper.ChangePasswordData data)
        {
            var passwordChangeHelper = new PasswordChangeHelper();

            return(await passwordChangeHelper.UpdatePassword(data.Email, data.Password) switch
            {
                DuplicateEmail => BadRequest("User with that email already exists."),
                RegistrationError => StatusCode(500, "An error occurred while trying to set password. Please try again later."),
                _ => Ok()
            });
Esempio n. 2
0
        public async Task When_changing_password_and_error_occurs()
        {
            var mockUserDataAccess = new Mock <IUserRepository>();

            mockUserDataAccess.Setup(x => x.InsertPasswordAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(0);

            var passwordChangeHelper = new PasswordChangeHelper(mockUserDataAccess.Object);

            var changePasswordData = new PasswordChangeHelper.ChangePasswordData
            {
                Email    = "*****@*****.**",
                Password = "******"
            };

            var result = await passwordChangeHelper.UpdatePassword(changePasswordData.Email, changePasswordData.Password);

            Assert.That(result, Is.EqualTo(0));
        }