public async Task <JsonResponse> Put(PasswordChangePair pcp) { var code = await accountService.changePassword(pcp.email, pcp.oldPassword, pcp.newPassword); HttpContext.Current.Response.StatusCode = (int)code; switch (code) { case HttpStatusCode.OK: return(new JsonResponse { status = "OK", message = "Password changed successfully.", showUser = true }); case HttpStatusCode.BadRequest: return(new JsonResponse { status = "Error", message = "False password.", showUser = true }); case HttpStatusCode.Conflict: return(new JsonResponse { status = "Error", message = "Database timeout.", showUser = false }); case HttpStatusCode.NotFound: return(new JsonResponse { status = "Error", message = "User not found.", showUser = false }); } return(new JsonResponse { status = "Error", message = "Error occured.", showUser = false }); }
public void putPasswordChangeNotFound() { //Arrange UserController controller = new UserController(); PasswordChangePair pair = new PasswordChangePair(); pair.email = ""; pair.oldPassword = "******"; pair.newPassword = "******"; //Act var task = controller.Put(pair); //Assert Assert.IsNotNull(task); }
public void putPasswordChangePairBadRequestTest() { //Arrange UserController controller = new UserController(); PasswordChangePair pair = new PasswordChangePair(); pair.email = "placetobecologne"; pair.oldPassword = "******"; pair.newPassword = "******"; //Act var task = controller.Put(pair); //Assert Assert.IsNotNull(task); }