Exemple #1
0
        public void DadoUmComandoInvalido()
        {
            var invalidCommand = new DeleteRegionCommand(0, "", "");

            invalidCommand.Validate();
            Assert.False(invalidCommand.Valid);
        }
Exemple #2
0
        public void DadoUmComandoValido()
        {
            var validCommand = new DeleteRegionCommand(1, "MG", "Minas Gerais");

            validCommand.Validate();
            Assert.True(validCommand.Valid);
        }
Exemple #3
0
        public void DadoUmComandoInvalidoPeloNome()
        {
            var invalidCommand = new DeleteRegionCommand(1, "MG", "");

            invalidCommand.Validate();
            Assert.Equal("O nome da região precisa ter pelo menos 3 letras.",
                         invalidCommand.Notifications.First().Message);
        }
Exemple #4
0
        public void DadoUmComandoInvalidoPelaSigla()
        {
            var invalidCommand = new DeleteRegionCommand(1, "", "Minas Gerais");

            invalidCommand.Validate();
            Assert.Equal("A sigla tem que ter pelo menos 1 letra.",
                         invalidCommand.Notifications.First().Message);
        }
Exemple #5
0
        public void DadoUmComandoInvalidoPelaId()
        {
            var invalidCommand = new DeleteRegionCommand(0, "MG", "Minas Gerais");

            invalidCommand.Validate();
            Assert.Equal("Identidade tem que ser maior que 0.",
                         invalidCommand.Notifications.First().Message);
        }
Exemple #6
0
        public async Task <APIResult> Delete([FromBody] DeleteRegionCommand command)
        {
            var rs = await mediator.Send(command);

            return(new APIResult()
            {
                Result = rs
            });
        }
Exemple #7
0
 public HandlerResult <DeleteRegionCommand> Delete(
     [FromServices] IHandler <DeleteRegionCommand> handler,
     [FromBody] DeleteRegionCommand command)
 {
     return(handler.Handle(command));
 }