Exemple #1
0
        public void CanDelete_should_throw_exception_if_role_not_found()
        {
            var command = new DeleteRole {
                Name = roleName
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppRoles.CanDelete(roles_0, command, contributors, clients));
        }
Exemple #2
0
        public void CanDelete_should_throw_exception_if_name_empty()
        {
            var command = new DeleteRole {
                Name = null
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanDelete(roles_0, command, contributors, clients),
                                    new ValidationError("Name is required.", "Name"));
        }
Exemple #3
0
        public void CanDelete_should_not_throw_exception_if_success()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new DeleteRole {
                Name = roleName
            };

            GuardAppRoles.CanDelete(roles_1, command, contributors, clients);
        }
Exemple #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));
        }
Exemple #5
0
        public void CanDelete_should_throw_exception_if_client_found()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new DeleteRole {
                Name = roleName
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanDelete(roles_1, command, contributors, clients.Add("1", new AppClient("client", "1", roleName))),
                                    new ValidationError("Cannot remove a role when a client is assigned."));
        }
Exemple #6
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(roles_1, command, contributors, clients),
                                    new ValidationError("Cannot delete a default role."));
        }
Exemple #7
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."));
        }