using Hutopy.Application.Common.Exceptions; using Hutopy.Application.Common.Security; using Hutopy.Application.TodoLists.Commands.CreateTodoList; using Hutopy.Application.TodoLists.Commands.PurgeTodoLists; using Hutopy.Domain.Entities; namespace Hutopy.Application.FunctionalTests.TodoLists.Commands; using static Testing; public class PurgeTodoListsTests : BaseTestFixture { [Test] public async Task ShouldDenyAnonymousUser() { var command = new PurgeTodoListsCommand(); command.GetType().Should().BeDecoratedWith(); var action = () => SendAsync(command); await action.Should().ThrowAsync(); } [Test] public async Task ShouldDenyNonAdministrator() { await RunAsDefaultUserAsync(); var command = new PurgeTodoListsCommand(); var action = () => SendAsync(command); await action.Should().ThrowAsync(); } [Test] public async Task ShouldAllowAdministrator() { await RunAsAdministratorAsync(); var command = new PurgeTodoListsCommand(); var action = () => SendAsync(command); await action.Should().NotThrowAsync(); } [Test] public async Task ShouldDeleteAllLists() { await RunAsAdministratorAsync(); await SendAsync(new CreateTodoListCommand { Title = "New List #1" }); await SendAsync(new CreateTodoListCommand { Title = "New List #2" }); await SendAsync(new CreateTodoListCommand { Title = "New List #3" }); await SendAsync(new PurgeTodoListsCommand()); var count = await CountAsync(); count.Should().Be(0); } }