using FluentAssertions; using MediatR; using Microsoft.Extensions.DependencyInjection; using MinAttest.Application.Features.Attests.Commands; using MinAttest.Application.Features.Attests.Queries; using MinAttest.Contracts.Attests; using Xunit; namespace MinAttest.Tests.Integration; [Collection("IntegrationCollection")] public class AttestsIntegrationTests { private readonly IntegrationTestFixture _fixture; public AttestsIntegrationTests(IntegrationTestFixture fixture) => _fixture = fixture; [Fact] public async Task Person_upload_and_list_attest_success() { var sp = _fixture.Services; var mediator = sp.GetRequiredService(); // Ensure person exists var upsert = await mediator.Send(new MinAttest.Application.Features.Persons.Commands.UpsertPersonCommand("person-hash-123", "person@example.com", null)); var personId = upsert.Id; var req = new PersonAttestUploadRequest( Title: "TestAttest", From: new DateOnly(2023,1,1), To: new DateOnly(2023,12,31), Summary: "Test summary", BlobPath: string.Empty, BlobHash: null, ContentBase64: Convert.ToBase64String(new byte[] {1,2,3}), ContentType: "application/octet-stream" ); var createdId = await mediator.Send(new PersonUploadAttestCommand(personId, req)); createdId.Should().NotBeNull(); var list = await mediator.Send(new ListPersonAttestsQuery(personId, 10)); list.Should().NotBeNull(); list!.Any(a => a.Id == createdId).Should().BeTrue(); } }