Ejemplo n.º 1
0
        public void CreateUserTest()
        {
            int    users_id    = 0;
            int    customer_id = 0;
            char   user_level  = 'j';
            char   condition   = 'c';
            string email       = "such@[email protected]";

            Random random = new Random();
            Users  users;

            List <string> errors = new List <string>();

            BLUser.CreateUser(null, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //users_id = 0
            errors = new List <string>();
            users  = new Users(users_id, 1, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //customer_id = 0
            errors = new List <string>();
            users  = new Users(1, customer_id, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //user_level = j
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", user_level,
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //condition = c
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, condition);
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //email = such@[email protected]
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", 'u',
                               email, DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //all 5
            errors = new List <string>();
            users  = new Users(users_id, customer_id, "username" + random.Next(10000), "password", user_level,
                               email, DateTime.Now, DateTime.Now, condition);
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(5, errors.Count);
            AsynchLog.LogNow(errors);

            //none
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(0, errors.Count);
            AsynchLog.LogNow(errors);
        }
Ejemplo n.º 2
0
 public void CreateUser(Users users, ref List <string> errors)
 {
     BLUser.CreateUser(users, ref errors);
 }