Ejemplo n.º 1
0
        public void Test()
        {
            var permissionCode    = DateTime.Now.Ticks.ToString();
            var addUserPermission = new AddUserPermissionViewModel()
            {
                UserID         = 1,
                PermissionCode = permissionCode
            };

            var biz = new UserPermissionBiz(_dbContext, _userService);

            var newUserPermission = biz.Add(addUserPermission, 0);

            Assert.IsTrue(newUserPermission.ID > 0);

            var temp = biz.Add(addUserPermission, 0);

            var lstUserPermission = _userService.GetUserPermissionList(addUserPermission.UserID);

            Assert.IsTrue(lstUserPermission.Contains(permissionCode));

            biz.Delete(newUserPermission.ID, 0);

            lstUserPermission = _userService.GetUserPermissionList(addUserPermission.UserID);

            Assert.IsFalse(lstUserPermission.Contains(permissionCode));

            if (newUserPermission.ID != temp.ID)
            {
                biz.Delete(temp.ID, 0);
            }

            Assert.AreEqual(newUserPermission.ID, temp.ID);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            var addUserPermission = new AddUserPermissionViewModel()
            {
                UserID         = 1,
                PermissionCode = $"{DateTime.Now.Ticks}"
            };

            var biz = new UserPermissionBiz(_dbContext);

            var newUserPermission = biz.Add(addUserPermission, 0);

            Assert.IsTrue(newUserPermission.ID > 0);

            var temp = biz.Add(addUserPermission, 0);

            biz.Delete(newUserPermission.ID, 0);

            if (newUserPermission.ID != temp.ID)
            {
                biz.Delete(temp.ID, 0);
            }

            Assert.AreEqual(newUserPermission.ID, temp.ID);

            var updateUserPermission = new MapperWrapper <UpdateUserPermissionViewModel, GetUserPermissionViewModel>().GetModel(newUserPermission);

            updateUserPermission.PermissionCode += "_D";
            biz.Update(updateUserPermission, 0);

            Assert.AreEqual(updateUserPermission.PermissionCode, biz.Get(newUserPermission.ID).PermissionCode);

            biz.Delete(newUserPermission.ID, 0);
        }
Ejemplo n.º 3
0
        public string Delete(int ID)
        {
            _biz.Delete(ID, User.GetUserID());

            return("success");
        }