-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: or-2519 dont allow to add lidmaatschap to verwijderde andere ve…
…reniging
- Loading branch information
Showing
16 changed files
with
359 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
534 changes: 154 additions & 380 deletions
534
src/AssociationRegistry/Resources/ExceptionMessages.Designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ationRegistry/Vereniging/Exceptions/VerenigingKanGeenLidWordenVanVerwijderdeVereniging.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace AssociationRegistry.Vereniging.Exceptions; | ||
|
||
using Be.Vlaanderen.Basisregisters.AggregateSource; | ||
using Resources; | ||
using System.Runtime.Serialization; | ||
|
||
[Serializable] | ||
public class VerenigingKanGeenLidWordenVanVerwijderdeVereniging : DomainException | ||
{ | ||
public VerenigingKanGeenLidWordenVanVerwijderdeVereniging() : base(ExceptionMessages.VerenigingKanGeenLidWordenVanVerwijderdeVereniging) | ||
{ | ||
} | ||
|
||
protected VerenigingKanGeenLidWordenVanVerwijderdeVereniging(SerializationInfo info, StreamingContext context) : base(info, context) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ging/When_Adding_Lidmaatschap/CommandHandling/Given_The_AndereVereniging_Is_Verwijderd.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace AssociationRegistry.Test.Admin.Api.Commands.FeitelijkeVereniging.When_Adding_Lidmaatschap.CommandHandling; | ||
|
||
using Acties.VoegLidmaatschapToe; | ||
using AssociationRegistry.Framework; | ||
using AutoFixture; | ||
using Common.AutoFixture; | ||
using Common.Framework; | ||
using Common.Scenarios.CommandHandling; | ||
using Events; | ||
using Moq; | ||
using Vereniging; | ||
using Vereniging.Exceptions; | ||
using Xunit; | ||
using Xunit.Categories; | ||
|
||
[UnitTest] | ||
public class Given_The_AndereVereniging_Is_Verwijderd | ||
{ | ||
[Fact] | ||
public async Task Then_It_Saves_A_Lidmaatschap() | ||
{ | ||
var fixture = new Fixture().CustomizeDomain(); | ||
var repositoryMock = new Mock<IVerenigingsRepository>(); | ||
|
||
var scenario = new FeitelijkeVerenigingWerdGeregistreerdScenario(); | ||
var lidmaatschap = fixture.Create<Lidmaatschap>(); | ||
|
||
repositoryMock | ||
.Setup(x => x.IsVerwijderd(lidmaatschap.AndereVereniging)) | ||
.ReturnsAsync(true); | ||
|
||
var commandHandler = new VoegLidmaatschapToeCommandHandler(repositoryMock.Object); | ||
|
||
var command = new VoegLidmaatschapToeCommand(scenario.VCode, | ||
lidmaatschap); | ||
|
||
await Assert.ThrowsAsync<VerenigingKanGeenLidWordenVanVerwijderdeVereniging>( | ||
async () => await commandHandler.Handle( | ||
new CommandEnvelope<VoegLidmaatschapToeCommand>(command, fixture.Create<CommandMetadata>()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...istry.Test.E2E/Scenarios/Givens/FeitelijkeVereniging/MultipleWerdGeregistreerdScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace AssociationRegistry.Test.E2E.Scenarios.Givens.FeitelijkeVereniging; | ||
|
||
using Events; | ||
using EventStore; | ||
using AssociationRegistry.Framework; | ||
using AssociationRegistry.Test.Common.AutoFixture; | ||
using Vereniging; | ||
using AutoFixture; | ||
using Requests.FeitelijkeVereniging; | ||
|
||
public class MultipleWerdGeregistreerdScenario : Framework.TestClasses.IScenario | ||
{ | ||
public FeitelijkeVerenigingWerdGeregistreerd FeitelijkeVerenigingWerdGeregistreerd { get; set; } | ||
public FeitelijkeVerenigingWerdGeregistreerd AndereFeitelijkeVerenigingWerdGeregistreerd { get; set; } | ||
private CommandMetadata Metadata; | ||
|
||
public MultipleWerdGeregistreerdScenario() | ||
{ | ||
} | ||
|
||
public async Task<Dictionary<string, IEvent[]>> GivenEvents(IVCodeService service) | ||
{ | ||
var fixture = new Fixture().CustomizeAdminApi(); | ||
|
||
FeitelijkeVerenigingWerdGeregistreerd = fixture.Create<FeitelijkeVerenigingWerdGeregistreerd>() with | ||
{ | ||
VCode = await service.GetNext(), | ||
}; | ||
AndereFeitelijkeVerenigingWerdGeregistreerd = fixture.Create<FeitelijkeVerenigingWerdGeregistreerd>() with | ||
{ | ||
VCode = await service.GetNext(), | ||
}; | ||
|
||
Metadata = fixture.Create<CommandMetadata>() with { ExpectedVersion = null }; | ||
|
||
return new Dictionary<string, IEvent[]>() | ||
{ | ||
{FeitelijkeVerenigingWerdGeregistreerd.VCode, [FeitelijkeVerenigingWerdGeregistreerd] }, | ||
{AndereFeitelijkeVerenigingWerdGeregistreerd.VCode, [AndereFeitelijkeVerenigingWerdGeregistreerd] }, | ||
}; | ||
} | ||
|
||
public IEvent[] GivenEvents() | ||
=> [FeitelijkeVerenigingWerdGeregistreerd]; | ||
|
||
public StreamActionResult Result { get; set; } = null!; | ||
|
||
public CommandMetadata GetCommandMetadata() | ||
=> Metadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ationRegistry.Test/VerenigingsRepositoryTests/When_Checking_If_Vereniging_IsVerwijderd.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
namespace AssociationRegistry.Test.VerenigingsRepositoryTests; | ||
|
||
using AutoFixture; | ||
using Common.AutoFixture; | ||
using Events; | ||
using EventStore; | ||
using FluentAssertions; | ||
using Framework; | ||
using Moq; | ||
using Vereniging; | ||
using Xunit; | ||
|
||
public class When_Checking_If_Vereniging_IsVerwijderd | ||
{ | ||
private readonly Fixture _fixture; | ||
|
||
public When_Checking_If_Vereniging_IsVerwijderd() | ||
{ | ||
_fixture = new Fixture().CustomizeDomain(); | ||
} | ||
|
||
[Fact] | ||
public async Task Given_A_Vereniging_IsVerwijderd() | ||
{ | ||
var eventStoreMock = new Mock<IEventStore>(); | ||
|
||
var verenigingState = new VerenigingState | ||
{ | ||
IsVerwijderd = true, | ||
}; | ||
|
||
eventStoreMock.Setup(x => x.Load<VerenigingState>(It.IsAny<string>(), null)) | ||
.ReturnsAsync(verenigingState); | ||
|
||
var sut = new VerenigingsRepository(eventStoreMock.Object); | ||
|
||
var actual = await sut.IsVerwijderd(VCode.Create(_fixture.Create<VCode>())); | ||
|
||
actual.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public async Task Given_A_Vereniging_IsNietVerwijderd() | ||
{ | ||
var eventStoreMock = new Mock<IEventStore>(); | ||
|
||
eventStoreMock.Setup(x => x.Load<VerenigingState>(It.IsAny<string>(), null)) | ||
.ReturnsAsync(new VerenigingState()); | ||
|
||
var sut = new VerenigingsRepository(eventStoreMock.Object); | ||
|
||
var actual = await sut.IsVerwijderd(VCode.Create(_fixture.Create<VCode>())); | ||
|
||
actual.Should().BeFalse(); | ||
} | ||
} |
16 changes: 8 additions & 8 deletions
16
...hen_Loading_A_Vereniging/Given_A_VCode.cs → ...hen_Loading_A_Vereniging/Given_A_VCode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...ng_a_vereniging/Given_A_New_Vereniging.cs → ...ng_a_vereniging/Given_A_New_Vereniging.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...ereniging/With_A_Duplicate_PhoneNumber.cs → ...ereniging/With_A_Duplicate_PhoneNumber.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters