예제 #1
0
        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");
            }
        }
예제 #2
0
        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");
            }
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        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");
            }
        }
예제 #5
0
        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");
            }
        }
예제 #6
0
        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
                }));
            }
        }