예제 #1
0
        public void CanRevoke_should_throw_execption_if_client_id_is_null()
        {
            var command = new RevokeClient();

            ValidationAssert.Throws(() => GuardAppClients.CanRevoke(command, App(clients_0)),
                                    new ValidationError("Client ID is required.", "Id"));
        }
예제 #2
0
        public void CanRevoke_should_throw_exception_if_client_is_not_found()
        {
            var command = new RevokeClient {
                Id = "ios"
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppClients.CanRevoke(command, App(clients_0)));
        }
예제 #3
0
        public void UpdateClient_should_throw_exception_if_client_is_not_found()
        {
            var command = new UpdateClient {
                Id = "ios", Name = "iOS"
            };

            Assert.Throws <DomainObjectNotFoundException>(() => GuardAppClients.CanUpdate(command, App(clients_0)));
        }
예제 #4
0
        public void CanRevoke_should_not_throw_exception_if_client_is_found()
        {
            var command = new RevokeClient {
                Id = "ios"
            };

            var clients_1 = clients_0.Add("ios", "secret");

            GuardAppClients.CanRevoke(command, App(clients_1));
        }
예제 #5
0
        public void CanAttach_should_not_throw_exception_if_client_is_free()
        {
            var command = new AttachClient {
                Id = "ios"
            };

            var clients_1 = clients_0.Add("android", "secret");

            GuardAppClients.CanAttach(command, App(clients_1));
        }
예제 #6
0
        public void UpdateClient_should_not_throw_exception_if_command_is_valid()
        {
            var command = new UpdateClient {
                Id = "ios", Name = "iOS", Role = Role.Reader
            };

            var clients_1 = clients_0.Add("ios", "secret");

            GuardAppClients.CanUpdate(command, App(clients_1));
        }
예제 #7
0
        public void UpdateClient_not_should_throw_exception_if_client_has_same_role()
        {
            var command = new UpdateClient {
                Id = "ios", Role = Role.Editor
            };

            var clients_1 = clients_0.Add("ios", "secret");

            GuardAppClients.CanUpdate(command, App(clients_1));
        }
예제 #8
0
        public void CanAttach_should_throw_exception_if_client_already_exists()
        {
            var command = new AttachClient {
                Id = "android"
            };

            var clients_1 = clients_0.Add("android", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanAttach(command, App(clients_1)),
                                    new ValidationError("A client with the same id already exists."));
        }
예제 #9
0
        public void UpdateClient_should_throw_exception_if_api_traffic_limit_is_less_than_zero()
        {
            var command = new UpdateClient {
                Id = "ios", ApiTrafficLimit = -10
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(command, App(clients_1)),
                                    new ValidationError("ApiTrafficLimit must be greater or equal to 0.", "ApiTrafficLimit"));
        }
예제 #10
0
        public void UpdateClient_should_throw_exception_if_client_has_invalid_role()
        {
            var command = new UpdateClient {
                Id = "ios", Role = "Invalid"
            };

            var clients_1 = clients_0.Add("ios", "secret");

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(command, App(clients_1)),
                                    new ValidationError("Role is not a valid value.", "Role"));
        }