Example #1
0
        public void InsertUserTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            UserDao userDao = new UserDao(database);
            InsertDummyData(userDao);
            Assert.Equal(items.Count, userDao.Count());
        }
Example #2
0
        public void FindAllUsersTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            UserDao userDao = new UserDao(database);
            InsertDummyData(userDao);
            Assert.Equal(items.Count, userDao.Count());

            IList<User> dbUsers = userDao.FindAll();
            Assert.NotNull(dbUsers);
            Assert.Equal(items.Count, dbUsers.Count);

            foreach(var user in dbUsers)
            {
                Assert.True(items.Contains(user));
            }
        }
Example #3
0
        public void FindUserByIdTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            UserDao userDao = new UserDao(database);
            InsertDummyData(userDao);
            Assert.Equal(items.Count, userDao.Count());

            User myUser = userDao.FindById(USER1_NAME);
            Assert.NotNull(myUser);
            Assert.Equal(USER1_NAME, myUser.Username);
            Assert.Equal(USER1_PASSWORD, myUser.Password);
            Assert.Equal(USER1_MAIL, myUser.Email);

            userDao.Delete(myUser.Username);
            Assert.Equal(3, userDao.Count());
        }
Example #4
0
        public void DeleteUserTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            UserDao userDao = new UserDao(database);
            InsertDummyData(userDao);
            Assert.Equal(items.Count, userDao.Count());

            foreach (var item in items)
            {
                userDao.Delete(item.Username);
            }
            Assert.Equal(0, userDao.Count());
        }
Example #5
0
        public void UpdateUserTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            UserDao userDao = new UserDao(database);
            InsertDummyData(userDao);
            Assert.Equal(items.Count, userDao.Count());


            userDao.Update(new User(USER1_NAME, ALTER_PASSWORD, ALTER_MAIL));
            var myNewUser = userDao.FindById(USER1_NAME);
            Assert.NotNull(myNewUser);
            Assert.True(!items.Contains(myNewUser));
            Assert.Equal(USER1_NAME, myNewUser.Username);
            Assert.Equal(ALTER_PASSWORD, myNewUser.Password);
            Assert.Equal(ALTER_MAIL, myNewUser.Email);

        }