Exemplo n.º 1
0
        public void CanDelete_should_throw_exception_if_name_empty()
        {
            var command = new DeleteRole {
                Name = null !
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanDelete(command, App(roles_0)),
                                    new ValidationError("Name is required.", "Name"));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 4
0
        public void CanDelete_should_not_throw_exception_if_command_is_valid()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new DeleteRole {
                Name = roleName
            };

            GuardAppRoles.CanDelete(command, App(roles_1));
        }
Exemplo n.º 5
0
        public void CanDelete_should_throw_exception_if_client_found()
        {
            var roles_1 = roles_0.Add("clientRole");

            var command = new DeleteRole {
                Name = "clientRole"
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanDelete(command, App(roles_1)),
                                    new ValidationError("Cannot remove a role when a client is assigned."));
        }
Exemplo n.º 6
0
        public void CanAdd_should_throw_exception_if_name_exists()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new AddRole {
                Name = roleName
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanAdd(command, App(roles_1)),
                                    new ValidationError("A role with the same name already exists."));
        }
Exemplo n.º 7
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."));
        }
Exemplo n.º 8
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"));
        }
Exemplo n.º 9
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"));
        }
Exemplo n.º 10
0
        public void CanDelete_should_throw_exception_if_default_role()
        {
            var roles_1 = roles_0.Add(Role.Developer);

            var command = new DeleteRole {
                Name = Role.Developer
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanDelete(command, App(roles_1)),
                                    new ValidationError("Cannot delete a default role."));
        }