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