public void UT_User_CreateAccount_UserExist() { var repo = new mockUserRepositoryUserExists(); var service = new UserCreateAccountV1(repo); if (service.Exec(null, new NewUserData { Name = "xxx", Email = "*****@*****.**", Password = "******" })) { Assert.Fail("CreateAccount // Existing user cannot create same account"); } }
public void UT_User_CreateAccount_PasswordInvalid_2() { var repo = new mockUserRepositoryUserExists(); var service = new UserCreateAccountV1(repo); if (service.Exec(null, new NewUserData { Name = "xxx", Email = "*****@*****.**", Password = "******" })) { Assert.Fail("CreateAccount // cannot be empty"); } }
public void UT_User_CreateAccount_EmailInvalid_3() { var repo = new mockUserRepositoryUserExists(); var service = new UserCreateAccountV1(repo); if (service.Exec(null, new NewUserData { Name = "xxx", Email = "fddd@fdsd" })) { Assert.Fail("CreateAccount // Email invalid 3 accepted"); } }
public void UT_User_CreateAccount_NameInvalid() { var repo = new mockUserRepositoryUserExists(); var service = new UserCreateAccountV1(repo); if (service.Exec(null, new NewUserData { Name = "" })) { Assert.Fail("CreateAccount // Name empty accepted"); } }
public void UT_User_CreateAccount_OK() { var repo = new mockUserRepositoryUserNotExists(); var service = new UserCreateAccountV1(repo); if (!service.Exec(null, new NewUserData { Name = "xxx", Email = "*****@*****.**", Password = "******" })) { Assert.Fail("CreateAccount // Not existing user should create account"); } }
public ActionResult <string> CreateAccount([FromBody] NewUserData newUser) { try { using (var db = new SqlConnection(GetDBConnectionString())) { var service = new UserCreateAccountV1(userRepository); if (!service.Exec(db, newUser)) { return(BadRequest(service.Error)); } return(Ok()); } } catch (System.Exception ex) { return(BadRequest(new ServiceError { DebugInfo = ex.ToString(), Message = _defaultError })); } }