using Hutopy.Application.Common.Exceptions; using Hutopy.Application.TodoItems.Commands.CreateTodoItem; using Hutopy.Application.TodoLists.Commands.CreateTodoList; using Hutopy.Domain.Entities; namespace Hutopy.Application.FunctionalTests.TodoItems.Commands; using static Testing; public class CreateTodoItemTests : BaseTestFixture { [Test] public async Task ShouldRequireMinimumFields() { var command = new CreateTodoItemCommand(); await FluentActions.Invoking(() => SendAsync(command)).Should().ThrowAsync(); } [Test] public async Task ShouldCreateTodoItem() { var userId = await RunAsDefaultUserAsync(); var listId = await SendAsync(new CreateTodoListCommand { Title = "New List" }); var command = new CreateTodoItemCommand { ListId = listId, Title = "Tasks" }; var itemId = await SendAsync(command); var item = await FindAsync(itemId); item.Should().NotBeNull(); item!.ListId.Should().Be(command.ListId); item.Title.Should().Be(command.Title); item.CreatedBy.Should().Be(userId); item.Created.Should().BeCloseTo(DateTime.Now, TimeSpan.FromMilliseconds(10000)); item.LastModifiedBy.Should().Be(userId); item.LastModified.Should().BeCloseTo(DateTime.Now, TimeSpan.FromMilliseconds(10000)); } }