コード例 #1
0
        public async Task ShouldUpdateTodoItem()
        {
            var userId = await RunAsDefaultUserAsync();

            var listId = await SendAsync(new CreateTodoListCommand
            {
                Title = "New List"
            });

            var itemId = await SendAsync(new CreateThrottlingCommand
            {
                ListId = listId,
                Title  = "New Item"
            });

            var command = new UpdateThrottlingCommand
            {
                Id    = itemId,
                Title = "Updated Item Title"
            };

            await SendAsync(command);

            var item = await FindAsync <TodoItem>(itemId);

            item.Title.Should().Be(command.Title);
            item.LastModifiedBy.Should().NotBeNull();
            item.LastModifiedBy.Should().Be(userId);
            item.LastModified.Should().NotBeNull();
            item.LastModified.Should().BeCloseTo(DateTime.Now, 1000);
        }
コード例 #2
0
        public async Task <IActionResult> Update([FromRoute] int id, [FromBody] UpdateThrottlingCommand command)
        {
            command.Id = id;
            await Mediator.Send(command);

            return(NoContent());
        }
コード例 #3
0
        public void ShouldRequireValidTodoItemId()
        {
            var command = new UpdateThrottlingCommand
            {
                Id    = 99,
                Title = "New Title"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }