public void Test_UserRolePrivilegeUpdate_Initialize()
        {
            var role = new UserRole
            {
                Id = 1,
                Title = "test",
                IsDefault = true,
                Privilege = Privileges.Create
            };

            var value = new UserRolePrivilegeUpdate();
            var roles = new List<UserRole> { role };

            var relations = new List<UserRoleRelation>
            {
                new UserRoleRelation
                {
                    Id = 1,
                    Privilege = Privileges.Update,
                    Role = role,
                    User = new User {Id = 1}
                }
            };

            value.Initialize(new User { Id = 1 }, roles, relations);

            Assert.AreEqual(1, value.Values.Count, "Values");
            Assert.AreEqual("test", value.Values[0].Role.Title, "Role.Title");
            Assert.AreEqual(2, value.Values[0].Privileges.Count(x => x.Selected), "Privilege");
        }
Exemplo n.º 2
0
        public void Test_UserRoleService_Insert()
        {
            var role = new UserRole { Title = "Test2" };

            this.UserRoleService.Insert(role);

            Assert.AreEqual("test2", role.Slug, "Slug");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserRoleDelete"/> class.
        /// </summary>
        /// <param name="role">The role.</param>
        public UserRoleDelete(UserRole role)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            this.Id = role.Id;
            this.Title = role.Title;
        }
Exemplo n.º 4
0
        public void Test_UserRoleService_InsertOrUpdate()
        {
            var privileges = new List<UserRoleRelationUpdateValue>
            {
                new UserRoleRelationUpdateValue {Privilege = 2, Selected = true},
                new UserRoleRelationUpdateValue {Privilege = 4, Selected = true}
            };

            var role = new UserRole { Title = "test4" };

            this.UserRoleService.InsertOrUpdate(role, privileges);

            Assert.AreEqual(2, role.Id, "Id");
            Assert.AreEqual("test4", role.Title, "Title");
            Assert.AreEqual(Privileges.ViewAny | Privileges.Create, role.Privilege, "Privilege");
        }
        public void Test_UserRoleCreateOrUpdate_ValueToModel()
        {
            var value = new UserRoleCreateOrUpdate
            {
                Title = "test",
                IsDefault = true,
                IsAdministrator = true,
                Privilege = Privileges.Create
            };

            var role = new UserRole();

            value.ValueToModel(role);

            Assert.AreEqual("test", role.Title, "Title");
            Assert.AreEqual(true, role.IsDefault, "IsDefault");
            Assert.AreEqual(true, role.IsAdministrator, "IsAdministrator");
        }
Exemplo n.º 6
0
 public void Update(UserRole entity)
 {
 }
Exemplo n.º 7
0
 public void InsertOrUpdate(UserRole role, IList<UserRoleRelationUpdateValue> privileges)
 {
 }
Exemplo n.º 8
0
 public void Insert(UserRole entity)
 {
 }
Exemplo n.º 9
0
 public void Delete(UserRole entity)
 {
 }