Пример #1
0
        public void TestList()
        {
            UserDao userDao = new UserDao(connectionString);
            RoleDao roleDao = new RoleDao(connectionString);

            Role role   = TestHelper.CreateRole();
            int  isSave = roleDao.Save(role);

            Assert.IsTrue(isSave > 0);

            User user1 = TestHelper.CreateUser();
            User user2 = TestHelper.CreateUser();

            role.Users = new List <User>();
            role.Users.Add(user1);
            role.Users.Add(user2);
            isSave = roleDao.Update(role);
            Assert.IsTrue(isSave > 0);

            IList <User> list = userDao.List(role.Id);

            Assert.AreEqual(2, list.Count);

            int isDelete = roleDao.Delete(role.Id);

            Assert.IsTrue(isDelete > 0);

            list = userDao.List(role.Id);
            Assert.AreEqual(0, list.Count);
        }
Пример #2
0
        public void Save_EqualTest(RoleDomain domain)
        {
            using (var tx = new TransactionScope())
            {
                int        id   = _roleDao.Save(domain);
                RoleDomain data = _roleDao.GetById(id);

                Assert.Equal(domain.RoleName, data.RoleName);
                Assert.Equal(domain.Status, data.Status);
                Assert.Equal(domain.UserIds, data.UserIds);
            }
        }
Пример #3
0
        public void TestCURD()
        {
            Role role = TestHelper.CreateRole();

            RoleDao roleDao = new RoleDao(connectionString);
            int     isSave  = roleDao.Save(role);

            Assert.IsTrue(isSave > 0);

            role.Name = "hello";
            int isUpdate = roleDao.Update(role);

            Assert.IsTrue(isUpdate > 0);

            int isDelete = roleDao.Delete(role.Id);

            Assert.IsTrue(isDelete > 0);
        }
Пример #4
0
        public void TestAddUser()
        {
            UserDao userDao = new UserDao(connectionString);
            RoleDao roleDao = new RoleDao(connectionString);

            User user = TestHelper.CreateUser();
            Role role = TestHelper.CreateRole();

            role.Users = new List <User>();
            role.Users.Add(user);
            int isSave = roleDao.Save(role);

            Assert.IsTrue(isSave > 0);

            user = TestHelper.CreateUser();
            role.Users.Add(user);
            isSave = roleDao.Update(role);
            Assert.IsTrue(isSave > 0);
        }
Пример #5
0
        public void TestSave()
        {
            int     isSave  = 0;
            UserDao userDao = new UserDao(connectionString);
            RoleDao roleDao = new RoleDao(connectionString);

            Role role = TestHelper.CreateRole();

            isSave = roleDao.Save(role);
            Assert.IsTrue(isSave > 0);

            User user = TestHelper.CreateUser();

            user.Roles = new List <Role>();
            user.Roles.Add(role);
            role = TestHelper.CreateRole();
            user.Roles.Add(role);
            isSave = userDao.Save(user);
            Assert.IsTrue(isSave > 0);
        }
Пример #6
0
 /// <summary>
 /// Save Role
 /// </summary>
 /// <param name="objRole"></param>
 public static void SaveRole(Role objRole)
 {
     RoleDao.Save(objRole);
 }