too much for one commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using EntKube.Identity.Domain;
|
||||
using EntKube.Identity.Features.GetTenants;
|
||||
using EntKube.Identity.Infrastructure;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace EntKube.Identity.Tests.Features;
|
||||
|
||||
public class GetTenantsHandlerTests
|
||||
{
|
||||
private readonly InMemoryTenantRepository repository;
|
||||
|
||||
public GetTenantsHandlerTests()
|
||||
{
|
||||
repository = new InMemoryTenantRepository();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllAsync_WithTenants_ReturnsList()
|
||||
{
|
||||
// Arrange — Two tenants exist in the repository.
|
||||
|
||||
Tenant tenant1 = Tenant.Create("Acme Corp", "acme", Guid.NewGuid());
|
||||
Tenant tenant2 = Tenant.Create("Globex", "globex", Guid.NewGuid());
|
||||
|
||||
await repository.AddAsync(tenant1);
|
||||
await repository.AddAsync(tenant2);
|
||||
|
||||
// Act — Retrieve all tenants via the repository (endpoint uses it directly).
|
||||
|
||||
IReadOnlyList<Tenant> tenants = await repository.GetAllAsync();
|
||||
|
||||
// Assert
|
||||
|
||||
tenants.Should().HaveCount(2);
|
||||
tenants.Should().Contain(t => t.Name == "Acme Corp");
|
||||
tenants.Should().Contain(t => t.Name == "Globex");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllAsync_Empty_ReturnsEmptyList()
|
||||
{
|
||||
// Act
|
||||
|
||||
IReadOnlyList<Tenant> tenants = await repository.GetAllAsync();
|
||||
|
||||
// Assert
|
||||
|
||||
tenants.Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user