Ejemplo n.º 1
0
        public async Task <ActionResult> Update(int id, UpdateTodoCategoryCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }
            await Mediator.Send(command);

            return(NoContent());
        }
Ejemplo n.º 2
0
        public void ShouldRequireValidTodoListId()
        {
            var command = new UpdateTodoCategoryCommand
            {
                Id            = 99,
                CategoryTitle = "New Title"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
Ejemplo n.º 3
0
        public async Task ShouldUpdateTodoList()
        {
            var userId = await RunAsDefaultUserAsync();

            var categoryId = await SendAsync(new CreateTodoCategoryCommand
            {
                CategoryTitle = "New List"
            });

            var command = new UpdateTodoCategoryCommand
            {
                Id            = categoryId,
                CategoryTitle = "Updated List Title"
            };

            await SendAsync(command);

            var list = await FindAsync <TodoCategory>(categoryId);

            list.CategoryTitle.Should().Be(command.CategoryTitle);
        }
Ejemplo n.º 4
0
        public async Task ShouldRequireUniqueTitle()
        {
            var categoryId = await SendAsync(new CreateTodoCategoryCommand
            {
                CategoryTitle = "New List"
            });

            await SendAsync(new CreateTodoCategoryCommand
            {
                CategoryTitle = "Other List"
            });

            var command = new UpdateTodoCategoryCommand
            {
                Id            = categoryId,
                CategoryTitle = "Other List"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command))
            .Should().Throw <ValidationException>().Where(ex => ex.Errors.ContainsKey("CategoryTitle"))
            .And.Errors["CategoryTitle"].Should().Contain("The specified title already exists.");
        }