Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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
                }));
            }
        }