First commit. Include junk from template to remove
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using Hutopy.Application.TodoItems.Commands.CreateTodoItem;
|
||||
using Hutopy.Application.TodoItems.Commands.UpdateTodoItem;
|
||||
using Hutopy.Application.TodoLists.Commands.CreateTodoList;
|
||||
using Hutopy.Domain.Entities;
|
||||
|
||||
namespace Hutopy.Application.FunctionalTests.TodoItems.Commands;
|
||||
|
||||
using static Testing;
|
||||
|
||||
public class UpdateTodoItemTests : BaseTestFixture
|
||||
{
|
||||
[Test]
|
||||
public async Task ShouldRequireValidTodoItemId()
|
||||
{
|
||||
var command = new UpdateTodoItemCommand { Id = 99, Title = "New Title" };
|
||||
await FluentActions.Invoking(() => SendAsync(command)).Should().ThrowAsync<NotFoundException>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ShouldUpdateTodoItem()
|
||||
{
|
||||
var userId = await RunAsDefaultUserAsync();
|
||||
|
||||
var listId = await SendAsync(new CreateTodoListCommand
|
||||
{
|
||||
Title = "New List"
|
||||
});
|
||||
|
||||
var itemId = await SendAsync(new CreateTodoItemCommand
|
||||
{
|
||||
ListId = listId,
|
||||
Title = "New Item"
|
||||
});
|
||||
|
||||
var command = new UpdateTodoItemCommand
|
||||
{
|
||||
Id = itemId,
|
||||
Title = "Updated Item Title"
|
||||
};
|
||||
|
||||
await SendAsync(command);
|
||||
|
||||
var item = await FindAsync<TodoItem>(itemId);
|
||||
|
||||
item.Should().NotBeNull();
|
||||
item!.Title.Should().Be(command.Title);
|
||||
item.LastModifiedBy.Should().NotBeNull();
|
||||
item.LastModifiedBy.Should().Be(userId);
|
||||
item.LastModified.Should().BeCloseTo(DateTime.Now, TimeSpan.FromMilliseconds(10000));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user