Пример #1
0
 public GenericCommandResult MarkAsDone(
     [FromBody] UpdateTodoCommand command,
     [FromServices] TodoHandler handler)
 {
     command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #2
0
        public void Dado_um_comando_valido_deve_criar_a_tarefa()
        {
            var command = new CreateTodoCommand("Titulo da Tarefa", "Administrador", DateTime.Now);
            var handler = new TodoHandler(new FakeTodoRepository());
            var result  = (GenericCommandResult)handler.Handle(command);

            Assert.AreEqual(result.Success, true);
        }
 public GenericCommandResult MarkAsUndone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = User.Claims.FirstOrDefault(x => x.Type == "name").Value;
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #4
0
        public void DadoUmComandoValidoDeveCriarTarefa()
        {
            var             command = new CreateTodoCommand("Titulo da Descrição", DateTime.Now, "Usuário");
            var             handle  = new TodoHandler(new FakeTodoRepository());
            ResponseCommand result  = (ResponseCommand)handle.Handle(command);

            Assert.AreEqual(result.Success, true);
        }
Пример #5
0
        public void Dado_um_comando_invalido_deve_interromper_a_execucao()
        {
            var command = new CreateTodoCommand("", "", DateTime.Now);
            var handler = new TodoHandler(new FakeTodoRepository());
            var result  = (GenericCommandResult)handler.Handle(command);

            Assert.AreEqual(result.Success, false);
        }
Пример #6
0
 public GenericCommandResult MarkAsUndone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #7
0
 public GenericCommandResult Create(
     [FromBody] CreateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #8
0
 public GenericCommandResult Update(
     [FromBody] UpdateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #9
0
        public void DadoUmComandoInvalidoDeveInterromperExecucao()
        {
            var             command = new CreateTodoCommand("", DateTime.Now, "");
            var             handle  = new TodoHandler(new FakeTodoRepository());
            ResponseCommand result  = (ResponseCommand)handle.Handle(command);

            Assert.AreEqual(result.Success, false);
        }
Пример #10
0
 public GenericCommandResult MarkAsUndone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #11
0
 public GenericCommandResult MarkAsUnDone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #12
0
 public GenericCommandResult Create(
     [FromBody] CreateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
 public GenericCommandResult MarkAsUndone(
     [FromBody] MarkTodoAsUndoneCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = getUserAuthenticated();
     return((GenericCommandResult)handler.Handle(command));
 }
 public GenericCommandResult Update(
     [FromBody] UpdateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = getUserAuthenticated();
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #15
0
        public GenericCommandResult MarkAsDone([FromBody] MarkTodoAsDoneCommand command,
                                               [FromServices] TodoHandler todoHandler)
        {
            var user = User.Claims.FirstOrDefault(us => us.Type.Equals("user_id"))?.Value;

            command.User = user;
            return((GenericCommandResult)todoHandler.Handle(command));
        }
Пример #16
0
 public GenericCommandResult Create(
     [FromBody] CreateTodoCommand command,
     [FromServices] TodoHandler handler
     )
 {
     command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;
     //command.User = "******";
     return((GenericCommandResult)handler.Handle(command));
 }
 public GenericCommandResult Create(
     [FromBody] CreateTodoCommand command, //Quando fizerem um post o Frombory converte o JSON no objeto
     [FromServices] TodoHandler handler    //A partir do que foi configurado no Startup.cs no AddTransient do Handler, vai resolver a dependência rapidamente
     )
 {
     command.User = getUserAuthenticated();
     //O command recebe os dados e passa para o Handler pois é ele quem vai tratar
     return((GenericCommandResult)handler.Handle(command));
 }
Пример #18
0
        public GenericCommandResult Create([FromBody] CreateTodoCommand command, [FromServices] TodoHandler todoHandler)
        {
            var t = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;

            command.User = "******";
            var commandResult = (GenericCommandResult)todoHandler.Handle(command);

            return(commandResult);
        }
Пример #19
0
        public GenericCommandResult Update(
            [FromBody] UpdateTodoCommand command,
            [FromServices] TodoHandler handler
            )
        {
            command.User = User.Claims.Where(x => x.Type == "name").FirstOrDefault().Value;

            return((GenericCommandResult)handler.Handle(command));
        }
Пример #20
0
        public GenericCommandResult Create(
            [FromBody] CreateTodoCommand command,
            [FromServices] TodoHandler handler
            )
        {
            string user = User.Claims.FirstOrDefault(a => a.Type == "user_id")?.Value;

            command.User = user;
            return((GenericCommandResult)handler.Handle(command));
        }
        public GenericCommandResult MarkTodoAsUndone(
            [FromBody] MarkTodoAsUndoneCommand command,
            [FromServices] TodoHandler handler
            )
        {
            var user = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;

            command.RefUser = user;
            return((GenericCommandResult)handler.Handle(command));
        }
Пример #22
0
        public GenericCommandResult Update(
            [FromBody] UpdateTodoCommand command,
            [FromServices] TodoHandler handler,
            [FromRoute] Guid id

            )
        {
            command.Id   = id;
            command.User = User.Claims.FirstOrDefault(x => x.Type == "user_id")?.Value;
            return((GenericCommandResult)handler.Handle(command));
        }
Пример #23
0
        public IActionResult Create([FromBody] CreateTodoCommand commandTodo)
        {
            try
            {
                commandTodo.User = "******";

                return(Ok((GenericCommandResult)_handler.Handle(commandTodo)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
 public void mark_as_done()
 {
     _result = (GenericCommandResult)_handler.Handle(_donecommand);
     Assert.AreEqual(_result.Success, true);
 }
Пример #25
0
 public GenericCommandResult MarkAsUndone([FromServices] TodoHandler handler, [FromBody] MarkTodoAsUndoneCommand command)
 {
     return((GenericCommandResult)handler.Handle(command));
 }
 public MarkAsUndoneTodoHandlerTests()
 {
     _invalidResult = (GenericCommandResult)_handle.Handle(new MarkTodoAsUndoneCommand());
     _validResult   = (GenericCommandResult)_handle.Handle(_invalidTodo);
 }
Пример #27
0
        public void Dado_um_comando_invalido_deve_interromper_a_execucao()
        {
            var result = (GenericCommandResult)_handler.Handle(_invalidCommad);

            Assert.AreEqual(result.Success, false);
        }
Пример #28
0
 public void Dado_um_comando_invalido_deve_interromper_a_execucao()
 {
     _result = (GenericCommandResult)_handler.Handle(_invalidCommand);
     Assert.IsFalse(_result.Success);
 }
 public void WhenInputCommandValidMustExecution()
 {
     _result = (GenericCommandResult)_handler.Handle(_validCommand);
     Assert.AreEqual(_result.Success, true);
 }
Пример #30
0
        public void Create_Todo_Handler_invalid_Command()
        {
            var handlerResult = (GenericCommandResult)_handler.Handle(_invalidCommand);

            Assert.AreEqual(handlerResult.Success, false);
        }