Files
minattest/backend/tests/MinAttest.Tests/Integration/EmployersAttestsIntegrationTests.cs
T
Stein Helge Riise ede31fbb7e Initial import
2025-11-17 08:32:46 +01:00

49 lines
1.9 KiB
C#

using FluentAssertions;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using MinAttest.Application.Features.Attests.Commands;
using MinAttest.Application.Features.Attests.Queries;
using MinAttest.Application.Features.Employers.Commands;
using MinAttest.Contracts.Attests;
using Xunit;
namespace MinAttest.Tests.Integration;
[Collection("IntegrationCollection")]
public class EmployersAttestsIntegrationTests
{
private readonly IntegrationTestFixture _fixture;
public EmployersAttestsIntegrationTests(IntegrationTestFixture fixture) => _fixture = fixture;
[Fact]
public async Task Employer_issue_and_list_attests()
{
var mediator = _fixture.Services.GetRequiredService<IMediator>();
// Ensure employer & person
var employer = await mediator.Send(new UpsertEmployerCommand("555555555", "NewCo AS"));
var person = await mediator.Send(new MinAttest.Application.Features.Persons.Commands.UpsertPersonCommand("person-hash-456", "person2@example.com", null));
var req = new EmployerAttestUploadRequest(
PersonId: person.Id,
Title: "IssuedAttest",
From: new DateOnly(2023,1,1),
To: new DateOnly(2023,12,31),
Summary: null,
BlobPath: string.Empty,
BlobHash: null,
ContentBase64: Convert.ToBase64String(new byte[]{4,5,6}),
ContentType: "application/octet-stream");
var createdId = await mediator.Send(new EmployerIssueAttestCommand(employer.Id, req));
createdId.Should().NotBeNull();
var list = await mediator.Send(new ListEmployerAttestsQuery(employer.Id, 10));
list.Should().Contain(a => a.Id == createdId);
// Content
var content = await mediator.Send(new GetAttestContentQuery(createdId!.Value));
content.Should().NotBeNull();
content!.Content.Length.Should().BeGreaterThan(0);
}
}