示例#1
0
        public void TestHasPermission()
        {
            string permName1 = Guid.NewGuid().ToString();
            long permId1 = psService.AddNew(permName1, permName1);
            string permName2 = Guid.NewGuid().ToString();
            long permId2= psService.AddNew(permName2, permName2);

            string roleName = Guid.NewGuid().ToString();
            long roleId = roleService.AddNew(roleName);

            string phone = CommonHelper.GetCaptcha(11);
            long uid = userService.AddAdminUser("abc", phone, "123456", "*****@*****.**", null);

            roleService.AddRoleIds(uid, new long[] { roleId });
            psService.AddPermissionIds(roleId, new long[] { permId1 });
            psService.GetByRoleId(5);
            psService.UpdatePermissionIds(roleId, new long[] { permId2 });
            Assert.IsFalse(userService.HasPermission(uid, permName1));
            Assert.IsTrue(userService.HasPermission(uid, permName2));
        }