52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using EntKube.Provisioning.Domain;
|
|
using EntKube.Provisioning.Features.Apps.DeleteApp;
|
|
using EntKube.Provisioning.Infrastructure;
|
|
using EntKube.SharedKernel.Domain;
|
|
using FluentAssertions;
|
|
|
|
namespace EntKube.Provisioning.Tests.Features;
|
|
|
|
public class DeleteAppHandlerTests
|
|
{
|
|
private readonly InMemoryAppRepository repository;
|
|
private readonly DeleteAppHandler handler;
|
|
|
|
public DeleteAppHandlerTests()
|
|
{
|
|
repository = new InMemoryAppRepository();
|
|
handler = new DeleteAppHandler(repository);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task HandleAsync_ExistingApp_DeletesSuccessfully()
|
|
{
|
|
// Arrange — An existing app in the repository.
|
|
|
|
App app = App.Create(Guid.NewGuid(), Guid.NewGuid(), "API", "api", AppType.Deployment);
|
|
await repository.AddAsync(app);
|
|
|
|
// Act
|
|
|
|
Result result = await handler.HandleAsync(app.Id);
|
|
|
|
// Assert — The app should be gone from the repository.
|
|
|
|
result.IsSuccess.Should().BeTrue();
|
|
App? deleted = await repository.GetByIdAsync(app.Id);
|
|
deleted.Should().BeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task HandleAsync_NonexistentApp_ReturnsFailure()
|
|
{
|
|
// Act
|
|
|
|
Result result = await handler.HandleAsync(Guid.NewGuid());
|
|
|
|
// Assert
|
|
|
|
result.IsFailure.Should().BeTrue();
|
|
result.Error.Should().Contain("not found");
|
|
}
|
|
}
|