Beispiel #1
0
        public void CanUpdate_should_throw_exception_if_role_does_not_exists()
        {
            var command = new UpdateRole {
                Name = roleName, Permissions = new[] { "P1" }
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppRoles.CanUpdate(command, App(roles_0)));
        }
Beispiel #2
0
        public void CanUpdate_should_not_throw_exception_if_role_exist_with_valid_command()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new UpdateRole {
                Name = roleName, Permissions = new[] { "P1" }
            };

            GuardAppRoles.CanUpdate(command, App(roles_1));
        }
Beispiel #3
0
        public void CanUpdate_should_not_throw_exception_if_properties_is_null()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new UpdateRole {
                Name = roleName, Permissions = new[] { "P1" }
            };

            GuardAppRoles.CanUpdate(command, App(roles_1));
        }
Beispiel #4
0
        public void CanUpdate_should_throw_exception_if_default_role()
        {
            var roles_1 = roles_0.Add(Role.Developer);

            var command = new UpdateRole {
                Name = Role.Developer, Permissions = new[] { "P1" }
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanUpdate(command, App(roles_1)),
                                    new ValidationError("Cannot update a default role."));
        }
Beispiel #5
0
        public void CanUpdate_should_throw_exception_if_permission_is_null()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new UpdateRole {
                Name = roleName
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanUpdate(command, App(roles_1)),
                                    new ValidationError("Permissions is required.", "Permissions"));
        }
Beispiel #6
0
        public void CanUpdate_should_throw_exception_if_name_empty()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new UpdateRole {
                Name = null !, Permissions = new[] { "P1" }
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanUpdate(command, App(roles_1)),
                                    new ValidationError("Name is required.", "Name"));
        }