Example #1
0
 public void Given_I_have_made_invalid_changes_to_an_existing_ToDo()
 {
     _existingItem = new ToDoItemBuilder().Persist();
     _updates      = Builder <UpdateToDoItemCommand> .CreateNew()
                     .Set(x => x.Title, string.Empty)
                     .Set(x => x.Id, _existingItem.Id);
 }
Example #2
0
 public void Given_I_have_made_valid_changes_to_an_existing_ToDo()
 {
     _existingItem = new ToDoItemBuilder().Persist();
     _updates      = Builder <UpdateToDoItemCommand> .CreateNew()
                     .Set(x => x.Description, "Updated")
                     .Set(x => x.Id, _existingItem.Id);
 }
Example #3
0
        public UpdateToDoItemCommand ItemToCommand(ToDoItem item)
        {
            UpdateToDoItemCommand command = new UpdateToDoItemCommand
            {
                ToDoItem = item
            };

            return(command);
        }
        public async Task HandleAsync(UpdateToDoItemCommand message)
        {
            var toDoItem = new ToDoItem()
            {
                Id          = message.Id,
                CategoryId  = message.CategoryId,
                Description = message.Description,
                Title       = message.Title,
                DueTo       = message.DueTo
            };

            await _uow.Commit();
        }
Example #5
0
        public async Task <IActionResult> EditItem(ToDoItemDTO item)
        {
            var command = new UpdateToDoItemCommand(
                item.Id,
                item.Title,
                item.Description,
                item.CategoryId,
                item.DueTo,
                item.Status,
                item.Path);

            await _commandHandler.HandleAsync(command);


            return(Ok());
        }
Example #6
0
        public void UpdateToDoItemTest()
        {
            var mediator  = new Mock <IMediator>();
            var patchToDo = new Mock <IPatchToDo>();
            UpdateToDoItemCommand command = new UpdateToDoItemCommand
            {
                ToDoItem = new BaseToDoItem()
                {
                    LabelId    = 2,
                    Name       = "Item 3",
                    IsComplete = false
                }
            };

            mediator.Setup(e => e.Send(command, new System.Threading.CancellationToken())).Returns(Task.FromResult(1));
            ToDoItemsController controller = new ToDoItemsController(patchToDo.Object, mediator.Object);
            var result   = controller.UpdateToDoItem(1, command);
            var response = result.Result as OkObjectResult;

            Assert.AreEqual(1, (int)response.Value);
        }
 public void Given_I_am_trying_to_edit_a_ToDo_that_does_not_exist()
 {
     _updates = Get.InstanceOf <UpdateToDoItemCommand>();
 }
 public async Task <ActionResult> UpdateToDoItem(int itemId, [FromBody] UpdateToDoItemCommand command)
 {
     command.ToDoItem.Id = itemId;
     return(Ok(await _mediator.Send(command)));
 }
Example #9
0
        public async Task <IActionResult> Update(UpdateToDoItemCommand command)
        {
            await Mediator.Send(command);

            return(Ok());
        }