Skip to content

Commit

Permalink
test: or-2353 add test for adding legal entity type
Browse files Browse the repository at this point in the history
  • Loading branch information
emalfroy authored and koenmetsu committed Sep 16, 2024
1 parent 71bdc00 commit fb709ae
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace OrganisationRegistry.UnitTests.Organisation.Kbo;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Api.Infrastructure.Magda;
using ElasticSearch.Organisations;
using FluentAssertions;
using Infrastructure.Tests.Extensions.TestHelpers;
using OrganisationRegistry.KeyTypes.Events;
Expand Down Expand Up @@ -282,6 +284,21 @@ await Given(Events)
organisationLabelAdded.ValidTo.Should().Be(new ValidTo());
}

[Fact]
public async Task AddsLegalEntityType()
{
await Given(Events)
.When(CoupleOrganisationToKboCommand, TestUser.AlgemeenBeheerder)
.Then();

var organisationLabelAdded = PublishedEvents.Where(evt=>evt.Body is KboLegalEntityTypeAdded).ToList()[0].UnwrapBody<KboLegalEntityTypeAdded>();
organisationLabelAdded.Should().NotBeNull();

organisationLabelAdded.OrganisationId.Should().Be(_organisationId);
organisationLabelAdded.LegalEntityTypeCode.Should().Be(MockMagdaOrganisationResponse.MockLegalEntityTypeCode);
organisationLabelAdded.LegalEntityTypeDescription.Should().Be(MockMagdaOrganisationResponse.MockLegalEntityType);
}

[Fact]
public async Task PublishesTheCorrectNumberOfEvents()
=> await Given(Events)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ await Given(Events)
organisationLabelAdded.Should().NotBeNull();

organisationLabelAdded.OrganisationId.Should().Be(_organisationId);
organisationLabelAdded.LegalEntityTypeCode.Should().Be("1");
organisationLabelAdded.LegalEntityTypeDescription.Should().Be("Natuurlijke Persoon");
organisationLabelAdded.LegalEntityTypeCode.Should().Be(MockMagdaOrganisationResponse.MockLegalEntityTypeCode);
organisationLabelAdded.LegalEntityTypeDescription.Should().Be(MockMagdaOrganisationResponse.MockLegalEntityType);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace OrganisationRegistry.UnitTests.Organisation.Kbo;

public class MockMagdaOrganisationResponse : IMagdaOrganisationResponse
{
public const string MockLegalEntityType = "Natuurlijke Persoon";
public const string MockLegalEntityTypeCode = "1";
public IMagdaName FormalName { get; set; } = null!;
public IMagdaName ShortName { get; set; } = null!;
public DateTime? ValidFrom { get; set; }
Expand All @@ -19,7 +21,7 @@ public class MockMagdaOrganisationResponse : IMagdaOrganisationResponse

public MockMagdaOrganisationResponse()
{
LegalEntityType = new MagdaLegalEntityType("1", "Natuurlijke Persoon");
LegalEntityType = new MagdaLegalEntityType(MockLegalEntityTypeCode, MockLegalEntityType);
BankAccounts = new List<IMagdaBankAccount>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ protected override KboOrganisationCommandHandlers BuildHandler(ISession session)


[Fact]
public async Task PublishesElevenEvents()
public async Task PublishesTheCorrectNumberOfEvents()
{
await Given(Events).When(SyncOrganisationWithKboCommand, TestUser.AlgemeenBeheerder)
.ThenItPublishesTheCorrectNumberOfEvents(12);
.ThenItPublishesTheCorrectNumberOfEvents(11);
}

[Fact]
Expand Down

0 comments on commit fb709ae

Please sign in to comment.