Initial import
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using FluentAssertions;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MinAttest.Application.Features.Employers.Commands;
|
||||
using MinAttest.Application.Features.Employers.Queries;
|
||||
using Xunit;
|
||||
|
||||
namespace MinAttest.Tests.Integration;
|
||||
|
||||
[Collection("IntegrationCollection")]
|
||||
public class EmployerUsersIntegrationTests
|
||||
{
|
||||
private readonly IntegrationTestFixture _fixture;
|
||||
public EmployerUsersIntegrationTests(IntegrationTestFixture fixture) => _fixture = fixture;
|
||||
[Fact]
|
||||
public async Task Upsert_list_get_delete_employer_user()
|
||||
{
|
||||
var mediator = _fixture.Services.GetRequiredService<IMediator>();
|
||||
|
||||
// Ensure employer exists
|
||||
var employer = await mediator.Send(new UpsertEmployerCommand("999999999", "TestBedrift AS"));
|
||||
|
||||
// Upsert user
|
||||
var user = await mediator.Send(new UpsertEmployerUserCommand(
|
||||
employer.Id, "oid-123", "hr@example.com", "Hr User", "Issuer"));
|
||||
user.Should().NotBeNull();
|
||||
|
||||
// List
|
||||
var list = await mediator.Send(new ListEmployerUsersQuery(employer.Id));
|
||||
list.Should().Contain(u => u.ExternalObjectId == "oid-123");
|
||||
|
||||
// Get
|
||||
var got = await mediator.Send(new GetEmployerUserQuery(employer.Id, user!.Id));
|
||||
got.Should().NotBeNull();
|
||||
got!.Email.Should().Be("hr@example.com");
|
||||
|
||||
// Delete
|
||||
var deleted = await mediator.Send(new DeleteEmployerUserCommand(employer.Id, user.Id));
|
||||
deleted.Should().BeTrue();
|
||||
|
||||
// Delete again -> false or idempotent? we return false when not found
|
||||
var deletedAgain = await mediator.Send(new DeleteEmployerUserCommand(employer.Id, user.Id));
|
||||
deletedAgain.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user