/// <summary> /// Method to test registering an invalid user with empty strings. /// </summary> public void CreateUserIncomplete_Login_ReturnsOutOfRange() { WeSketchSecurity Sec = new WeSketchSecurity(); var ex = Assert.Catch <ArgumentOutOfRangeException>(() => Sec.CreateUser("", "", "")); StringAssert.Contains("System.ArgumentOutOfRangeException", ex.Message); }
public void CreateValidUser_CreateUser_ReturnsUser() { WeSketchSecurity Sec = new WeSketchSecurity(); User usr = Sec.CreateUser("testerSec", "TestPasswordSec", "*****@*****.**"); Assert.IsNotNull(usr); }
public void CreateExistingUser_CreateUser_ReturnsAlreadyExistsError() { WeSketchSecurity Sec = new WeSketchSecurity(); var ex = Assert.Catch <Exception>(() => Sec.CreateUser("testerExists", "TestPasswordExists", "*****@*****.**")); StringAssert.Contains("already exists.", ex.Message); }
public string CreateUser(string user, string password, string email) { var result = new Result(); try { WeSketchSecurity security = new WeSketchSecurity(); User newUser = security.CreateUser(user, password, email); WeSketchSharedDataModels.User newUserModel = new WeSketchSharedDataModels.User() { UserID = newUser.UserID, UserName = newUser.UserName, Board = new Board() { BoardID = newUser.UserBoard.BoardID, Owner = newUser.UserBoard.BoardOwner } }; result.ResultJSON = JsonConvert.SerializeObject(newUserModel); } catch (Exception e) { result.Error = true; result.ErrorMessage = e.Message; } return(JsonConvert.SerializeObject(result)); }