First commit. Include junk from template to remove

This commit is contained in:
Dominic Villemure
2024-03-09 20:25:30 -05:00
commit bbcefcf76f
140 changed files with 8151 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
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<AuthorizeAttribute>();
var action = () => SendAsync(command);
await action.Should().ThrowAsync<UnauthorizedAccessException>();
}
[Test]
public async Task ShouldDenyNonAdministrator()
{
await RunAsDefaultUserAsync();
var command = new PurgeTodoListsCommand();
var action = () => SendAsync(command);
await action.Should().ThrowAsync<ForbiddenAccessException>();
}
[Test]
public async Task ShouldAllowAdministrator()
{
await RunAsAdministratorAsync();
var command = new PurgeTodoListsCommand();
var action = () => SendAsync(command);
await action.Should().NotThrowAsync<ForbiddenAccessException>();
}
[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<TodoList>();
count.Should().Be(0);
}
}