32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
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 EmployersIntegrationTests
|
|
{
|
|
private readonly IntegrationTestFixture _fixture;
|
|
public EmployersIntegrationTests(IntegrationTestFixture fixture) => _fixture = fixture;
|
|
[Fact]
|
|
public async Task Upsert_and_get_and_list_employers_work()
|
|
{
|
|
var mediator = _fixture.Services.GetRequiredService<IMediator>();
|
|
|
|
var upsert = await mediator.Send(new UpsertEmployerCommand("123456789", "Acme AS"));
|
|
upsert.OrgNumber.Should().Be("123456789");
|
|
upsert.Name.Should().Be("Acme AS");
|
|
|
|
var list = await mediator.Send(new ListEmployersQuery());
|
|
list.Should().Contain(e => e.OrgNumber == "123456789");
|
|
|
|
var get = await mediator.Send(new GetEmployerQuery(upsert.Id));
|
|
get.Should().NotBeNull();
|
|
get!.Name.Should().Be("Acme AS");
|
|
}
|
|
}
|