示例#1
0
文件: UserTest.cs 项目: amigobv/UFO
        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());
        }
示例#2
0
文件: UserTest.cs 项目: amigobv/UFO
        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));
            }
        }
示例#3
0
文件: UserTest.cs 项目: amigobv/UFO
        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());
        }
示例#4
0
文件: UserTest.cs 项目: amigobv/UFO
        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());
        }
示例#5
0
文件: UserTest.cs 项目: amigobv/UFO
        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);

        }