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 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 tenants = await repository.GetAllAsync(); // Assert tenants.Should().BeEmpty(); } }