-
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-2521 prevent lidmaatschap referring to self
- Loading branch information
Showing
11 changed files
with
599 additions
and
151 deletions.
There are no files selected for viewing
545 changes: 399 additions & 146 deletions
545
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
16 changes: 16 additions & 0 deletions
16
src/AssociationRegistry/Vereniging/Lidmaatschappen/Exceptions/LidmaatschapIsOverlappend.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,16 @@ | ||
namespace AssociationRegistry.Vereniging.Exceptions; | ||
|
||
using Be.Vlaanderen.Basisregisters.AggregateSource; | ||
using Resources; | ||
using System.Runtime.Serialization; | ||
|
||
public class LidmaatschapIsOverlappend : DomainException | ||
{ | ||
public LidmaatschapIsOverlappend() : base(ExceptionMessages.LidmaatschapIsOverlappend) | ||
{ | ||
} | ||
|
||
protected LidmaatschapIsOverlappend(SerializationInfo info, StreamingContext context) : base(info, context) | ||
{ | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
.../Vereniging/Lidmaatschappen/Exceptions/LidmaatschapMagNietVerwijzenNaarEigenVereniging.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,16 @@ | ||
namespace AssociationRegistry.Vereniging.Exceptions; | ||
|
||
using Be.Vlaanderen.Basisregisters.AggregateSource; | ||
using Resources; | ||
using System.Runtime.Serialization; | ||
|
||
public class LidmaatschapMagNietVerwijzenNaarEigenVereniging : DomainException | ||
{ | ||
public LidmaatschapMagNietVerwijzenNaarEigenVereniging() : base(ExceptionMessages.LidmaatschapMagNietVerwijzenNaarEigenVereniging) | ||
{ | ||
} | ||
|
||
protected LidmaatschapMagNietVerwijzenNaarEigenVereniging(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
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
39 changes: 39 additions & 0 deletions
39
.../When_Adding_A_Lidmaatschap/Given_An_Overlapping_Periode_For_Another_Andere_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace AssociationRegistry.Test.LidmaatschappenTests.When_Adding_A_Lidmaatschap; | ||
|
||
using AutoFixture; | ||
using Common.AutoFixture; | ||
using FluentAssertions; | ||
using Vereniging; | ||
using Xunit; | ||
|
||
public class Given_An_Overlapping_Periode_For_Another_Andere_Vereniging | ||
{ | ||
[Fact] | ||
public void Then_It_Returns_With_Next_Id() | ||
{ | ||
var fixture = new Fixture().CustomizeDomain(); | ||
|
||
var andereVereniging = fixture.Create<VCode>(); | ||
var bestaandLidmaatschap = fixture.Create<Lidmaatschap>() with | ||
{ | ||
LidmaatschapId = 1, | ||
AndereVereniging = andereVereniging, | ||
Geldigheidsperiode = Geldigheidsperiode.Infinity, | ||
}; | ||
var toeTeVoegenLidmaatschap = fixture.Create<Lidmaatschap>() with | ||
{ | ||
AndereVereniging = fixture.Create<VCode>(), | ||
}; | ||
|
||
var sut = Lidmaatschappen.Empty.Hydrate([ | ||
bestaandLidmaatschap, | ||
]); | ||
|
||
var actual = sut.VoegToe(toeTeVoegenLidmaatschap); | ||
|
||
actual.Should().BeEquivalentTo(toeTeVoegenLidmaatschap with | ||
{ | ||
LidmaatschapId = bestaandLidmaatschap.LidmaatschapId + 1, | ||
}); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...When_Adding_A_Lidmaatschap/Given_An_Overlapping_Periode_For_The_Same_Andere_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace AssociationRegistry.Test.LidmaatschappenTests.When_Adding_A_Lidmaatschap; | ||
|
||
using AutoFixture; | ||
using Common.AutoFixture; | ||
using FluentAssertions; | ||
using Resources; | ||
using Vereniging; | ||
using Vereniging.Exceptions; | ||
using Xunit; | ||
|
||
public class Given_An_Overlapping_Periode_For_The_Same_Andere_Vereniging | ||
{ | ||
[Fact] | ||
public void Then_It_Throws() | ||
{ | ||
var fixture = new Fixture().CustomizeDomain(); | ||
|
||
var andereVereniging = fixture.Create<VCode>(); | ||
var bestaandLidmaatschap = fixture.Create<Lidmaatschap>() with | ||
{ | ||
AndereVereniging = andereVereniging, | ||
Geldigheidsperiode = Geldigheidsperiode.Infinity, | ||
}; | ||
var toeTeVoegenLidmaatschap = fixture.Create<Lidmaatschap>() with | ||
{ | ||
AndereVereniging = andereVereniging, | ||
}; | ||
|
||
var sut = Lidmaatschappen.Empty.Hydrate([ | ||
bestaandLidmaatschap, | ||
]); | ||
|
||
var exception = Assert.Throws<LidmaatschapIsOverlappend>(() => sut.VoegToe(toeTeVoegenLidmaatschap)); | ||
exception.Message.Should().Be(ExceptionMessages.LidmaatschapIsOverlappend); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...When_Adding_A_Lidmaatschap/Given_No_Overlapping_Periode_For_The_Same_Andere_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace AssociationRegistry.Test.LidmaatschappenTests.When_Adding_A_Lidmaatschap; | ||
|
||
using AutoFixture; | ||
using Common.AutoFixture; | ||
using FluentAssertions; | ||
using Vereniging; | ||
using Xunit; | ||
|
||
public class Given_No_Overlapping_Periode_For_The_Same_Andere_Vereniging | ||
{ | ||
[Fact] | ||
public void Then_It_Adds() | ||
{ | ||
var fixture = new Fixture().CustomizeDomain(); | ||
|
||
var andereVereniging = fixture.Create<VCode>(); | ||
|
||
var bestaandLidmaatschap = fixture.Create<Lidmaatschap>() with | ||
{ | ||
AndereVereniging = andereVereniging, | ||
Geldigheidsperiode = new Geldigheidsperiode(new GeldigVan(1999, 10, 10), new GeldigTot(1999, 10, 10)), | ||
}; | ||
|
||
var toeTeVoegenLidmaatschap = fixture.Create<Lidmaatschap>() with | ||
{ | ||
AndereVereniging = andereVereniging, | ||
Geldigheidsperiode = new Geldigheidsperiode(new GeldigVan(2020, 10, 10), new GeldigTot(2020, 10, 10)), | ||
}; | ||
|
||
var sut = Lidmaatschappen.Empty.Hydrate([ | ||
bestaandLidmaatschap, | ||
]); | ||
|
||
var actual = sut.VoegToe(toeTeVoegenLidmaatschap); | ||
|
||
actual.Should().BeEquivalentTo(toeTeVoegenLidmaatschap with | ||
{ | ||
LidmaatschapId = bestaandLidmaatschap.LidmaatschapId + 1, | ||
}); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ociationRegistry.Test/When_VoegLidmaatschapToe/Given_AndereVerwijstNaamEigenVereniging.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,30 @@ | ||
namespace AssociationRegistry.Test.When_VoegLidmaatschapToe; | ||
|
||
using AutoFixture; | ||
using Common.AutoFixture; | ||
using Events; | ||
using FluentAssertions; | ||
using Resources; | ||
using Vereniging; | ||
using Vereniging.Exceptions; | ||
using Xunit; | ||
|
||
public class Given_AndereVerwijstNaamEigenVereniging | ||
{ | ||
[Fact] | ||
public void Then_Throws() | ||
{ | ||
var fixture = new Fixture().CustomizeDomain(); | ||
|
||
var sut = new VerenigingOfAnyKind(); | ||
var feitelijkeVerenigingWerdGeregistreerd = fixture.Create<FeitelijkeVerenigingWerdGeregistreerd>(); | ||
sut.Hydrate(new VerenigingState().Apply(feitelijkeVerenigingWerdGeregistreerd)); | ||
|
||
var exception = Assert.Throws<LidmaatschapMagNietVerwijzenNaarEigenVereniging>(() => sut.VoegLidmaatschapToe(fixture.Create<Lidmaatschap>() with | ||
{ | ||
AndereVereniging = VCode.Create(feitelijkeVerenigingWerdGeregistreerd.VCode), | ||
})); | ||
|
||
exception.Message.Should().Be(ExceptionMessages.LidmaatschapMagNietVerwijzenNaarEigenVereniging); | ||
} | ||
} |