Пример #1
0
        public void AddToDoListTest()
        {
            var mediator  = new Mock <IMediator>();
            var patchToDo = new Mock <IPatchToDo>();
            var todoItem  = new Domain.Models.BaseToDoItem()
            {
                IsComplete = true,
                LabelId    = 1,
                Name       = "Item 1",
                UserId     = 1
            };
            AddToDoListCommand command = new AddToDoListCommand
            {
                ToDoList = new Domain.Models.BaseToDoList()
                {
                    LabelId   = 1,
                    Name      = "List 1",
                    TodoItems = new List <Domain.Models.BaseToDoItem>()
                    {
                        todoItem
                    },
                    UserId = 1
                }
            };

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

            Assert.AreEqual(1, (int)response.Value);
        }
 public async Task <ActionResult> AddToDoList([FromBody] AddToDoListCommand command)
 {
     return(Ok(await _mediator.Send(command)));
 }