diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressAlreadyAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressAlreadyAttached.cs index 3c1ff096..031f1e78 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressAlreadyAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressAlreadyAttached.cs @@ -1,14 +1,10 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress { - using System.Collections.Generic; using Api.BackOffice.Abstractions.Extensions; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using Fixtures; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Xunit; using Xunit.Abstractions; @@ -26,25 +22,15 @@ public void ThenNothing() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new AttachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new AttachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - addressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Realized) + .WithAddress(addressPersistentLocalId) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressDoesNotExist.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressDoesNotExist.cs index 1007e5cf..7536eaa3 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressDoesNotExist.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressDoesNotExist.cs @@ -1,14 +1,9 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using Fixtures; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Parcel.Exceptions; using Xunit; using Xunit.Abstractions; @@ -25,25 +20,14 @@ public GivenAddressDoesNotExist(ITestOutputHelper testOutputHelper) : base(testO [Fact] public void ThenThrowAddressNotFoundException() { - var command = new AttachAddress( - Fixture.Create(), - new AddressPersistentLocalId(11111111), - Fixture.Create()); + var command = new AttachAddressBuilder(Fixture) + .WithAddress(11111111) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(123), - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Realized) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressHasInvalidStatus.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressHasInvalidStatus.cs index fa229ed2..947ca1ab 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressHasInvalidStatus.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressHasInvalidStatus.cs @@ -1,23 +1,18 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Parcel.Exceptions; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressHasInvalidStatus : ParcelRegistryTest { @@ -32,29 +27,17 @@ public GivenAddressHasInvalidStatus(ITestOutputHelper testOutputHelper) : base(t [Theory] [InlineData("Rejected")] [InlineData("Retired")] - public void ThenThrowAddressHasInvalidStatusException(string addressStatus) + public void ThenThrowsAddressHasInvalidStatusException(string addressStatus) { var addressPersistentLocalId = new AddressPersistentLocalId(11111111); - var command = new AttachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new AttachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(123), - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressIsRemoved.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressIsRemoved.cs index f8cc8fa0..a685474b 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressIsRemoved.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressIsRemoved.cs @@ -1,23 +1,18 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Parcel.Exceptions; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressIsRemoved : ParcelRegistryTest { @@ -33,25 +28,13 @@ public void ThenThrowAddressIsRemovedException() { var addressPersistentLocalId = new AddressPersistentLocalId(11111111); - var command = new AttachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new AttachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(123), - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressNotAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressNotAttached.cs index d220d255..e0003395 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressNotAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenAddressNotAttached.cs @@ -1,7 +1,6 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress { using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; @@ -10,16 +9,15 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using FluentAssertions; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressNotAttached : ParcelRegistryTest { @@ -35,25 +33,13 @@ public void ThenParcelAddressWasAttachedV2() { var addressPersistentLocalId = new AddressPersistentLocalId(111); - var command = new AttachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new AttachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(123), - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( @@ -75,20 +61,10 @@ public void ThenParcelAddressWasAttachedV2() [Fact] public void StateCheck() { - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - Fixture.Create(), - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(123), - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(123) + .Build(); var addressPersistentLocalId = new AddressPersistentLocalId(111); var parcelAddressWasAttachedV2 = new ParcelAddressWasAttachedV2(Fixture.Create(), new VbrCaPaKey(parcelWasMigrated.CaPaKey), addressPersistentLocalId); @@ -99,7 +75,7 @@ public void StateCheck() sut.Initialize(new List { parcelWasMigrated, parcelAddressWasAttachedV2 }); // Assert - sut.AddressPersistentLocalIds.Should().HaveCount(4); + sut.AddressPersistentLocalIds.Should().HaveCount(2); sut.AddressPersistentLocalIds.Should().Contain(addressPersistentLocalId); sut.LastEventHash.Should().Be(parcelAddressWasAttachedV2.GetHash()); } diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelHasInvalidStatus.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelHasInvalidStatus.cs index 6ffb5f8b..9dc09720 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelHasInvalidStatus.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelHasInvalidStatus.cs @@ -1,23 +1,18 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Parcel.Exceptions; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenParcelHasInvalidStatus : ParcelRegistryTest { @@ -31,27 +26,15 @@ public GivenParcelHasInvalidStatus(ITestOutputHelper testOutputHelper) : base(te [Fact] public void ThenThrowParcelHasInvalidStatusException() { - var addressPersistentLocalId = new AddressPersistentLocalId(11111111); + var addressPersistentLocalId = Fixture.Create(); - var command = new AttachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new AttachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Retired, - isRemoved: false, - new List - { - new AddressPersistentLocalId(123), - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Retired) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelIsRemoved.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelIsRemoved.cs index 189dfa3e..b531004a 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelIsRemoved.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenAttachingParcelAddress/GivenParcelIsRemoved.cs @@ -1,26 +1,12 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; - using Autofac; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; + using Fixtures; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Parcel.Exceptions; - using BackOffice; - using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; - using Consumer.Address; - using Fixtures; - using NetTopologySuite; - using NetTopologySuite.Geometries; - using NetTopologySuite.Geometries.Implementation; - using NetTopologySuite.IO; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenParcelIsRemoved : ParcelRegistryTest { @@ -36,32 +22,14 @@ public void ThenThrowParcelIsRemovedException() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new AttachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); - - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: true, - new List - { - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var command = new AttachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var consumerAddress = Container.Resolve(); - consumerAddress.AddAddress( - addressPersistentLocalId, - AddressStatus.Current, - "DerivedFromObject", - "Parcel", - (Point)_wkbReader.Read(Fixture.Create().ToString().ToByteArray())); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithIsRemoved() + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelDoesNotExist.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelDoesNotExist.cs index 4136343a..b0aaafd1 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelDoesNotExist.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelDoesNotExist.cs @@ -1,14 +1,9 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenChangingParcelGeometry { - using System; - using System.Collections.Generic; using Api.BackOffice.Abstractions.Extensions; - using AutoFixture; - using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; @@ -21,11 +16,8 @@ public GivenParcelDoesNotExist(ITestOutputHelper testOutputHelper) : base(testOu [Fact] public void ThenParcelWasImported() { - var command = new ChangeParcelGeometry( - Fixture.Create(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), - new List(), - Fixture.Create()); + var command = new ChangeParcelGeometryBuilder(Fixture) + .Build(); Assert(new Scenario() .Given() diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelExists.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelExists.cs index fb8aeae6..f96e148c 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelExists.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelExists.cs @@ -1,16 +1,13 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenChangingParcelGeometry { - using System.Collections.Generic; using Api.BackOffice.Abstractions.Extensions; using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using EventExtensions; + using Builders; using FluentAssertions; using Moq; using Parcel; - using Parcel.Commands; using Parcel.Events; using Parcel.Exceptions; using Xunit; @@ -29,17 +26,15 @@ public void ThenParcelGeometryChanged() var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); - var command = new ChangeParcelGeometry( - caPaKey, - GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry(), - new List(), - Fixture.Create()); + var command = new ChangeParcelGeometryBuilder(Fixture) + .WithVbrCaPaKey(caPaKey) + .WithExtendedWkbGeometry(GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry()) + .Build(); Assert(new Scenario() .Given(new ParcelStreamId(parcelId), parcelWasImported) @@ -54,37 +49,33 @@ public void WithAddresses_ThenParcelAddressesAreAttachedAndDetached() var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); var addressPersistentLocalIdToAttach = new AddressPersistentLocalId(1); var addressPersistentLocalIdToDoNothing = new AddressPersistentLocalId(2); var addressPersistentLocalIdToDetach = new AddressPersistentLocalId(3); - var toDoNothingParcelAddressWasAttached = new ParcelAddressWasAttachedV2( - parcelId, - caPaKey, - addressPersistentLocalIdToDoNothing); - toDoNothingParcelAddressWasAttached.SetFixtureProvenance(Fixture); - - var toDetachParcelAddressWasAttached = new ParcelAddressWasAttachedV2( - parcelId, - caPaKey, - addressPersistentLocalIdToDetach); - toDetachParcelAddressWasAttached.SetFixtureProvenance(Fixture); - - var command = new ChangeParcelGeometry( - caPaKey, - GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry(), - new List() - { - addressPersistentLocalIdToAttach, - addressPersistentLocalIdToDoNothing - }, - Fixture.Create()); + var toDoNothingParcelAddressWasAttached = new ParcelAddressWasAttachedV2Builder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .WithAddress(addressPersistentLocalIdToDoNothing) + .Build(); + + var toDetachParcelAddressWasAttached = new ParcelAddressWasAttachedV2Builder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .WithAddress(addressPersistentLocalIdToDetach) + .Build(); + + var command = new ChangeParcelGeometryBuilder(Fixture) + .WithVbrCaPaKey(caPaKey) + .WithExtendedWkbGeometry(GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry()) + .WithAddress(addressPersistentLocalIdToAttach) + .WithAddress(addressPersistentLocalIdToDoNothing) + .Build(); Assert(new Scenario() .Given(new ParcelStreamId(parcelId), @@ -104,22 +95,14 @@ public void WhenGeometryIsTheSame_ThenNone() var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var extendedWkbGeometry = GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(); - var command = new ChangeParcelGeometry( - caPaKey, - extendedWkbGeometry, - new List(), - Fixture.Create()); - - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Retired, - isRemoved: false, - new List(), - extendedWkbGeometry); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var command = new ChangeParcelGeometryBuilder(Fixture) + .WithVbrCaPaKey(caPaKey) + .Build(); + + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Retired) + .Build(); Assert(new Scenario() .Given(new ParcelStreamId(parcelId), parcelWasMigrated) @@ -133,17 +116,15 @@ public void WithInvalidPolygon_ThenThrowsPolygonIsInvalidException() var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); - var command = new ChangeParcelGeometry( - caPaKey, - GeometryHelpers.GmlPointGeometry.GmlToExtendedWkbGeometry(), - new List(), - Fixture.Create()); + var command = new ChangeParcelGeometryBuilder(Fixture) + .WithVbrCaPaKey(caPaKey) + .WithExtendedWkbGeometry(GeometryHelpers.GmlPointGeometry.GmlToExtendedWkbGeometry()) + .Build(); Assert(new Scenario() .Given(new ParcelStreamId(parcelId), parcelWasImported) @@ -157,14 +138,16 @@ public void StateCheck() var parcelId = Fixture.Create(); var caPaKey = Fixture.Create(); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); - var parcelGeometryWasChanged = new ParcelGeometryWasChanged(parcelId, caPaKey, GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry()); - parcelGeometryWasChanged.SetFixtureProvenance(Fixture); + var parcelGeometryWasChanged = new ParcelGeometryWasChangedBuilder(Fixture) + .WithParcelId(parcelId) + .WithVbrCaPaKey(caPaKey) + .WithExtendedWkbGeometry(GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry()) + .Build(); var parcel = new ParcelFactory(NoSnapshotStrategy.Instance, new Mock().Object).Create(); parcel.Initialize(new object[] diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelIsRemoved.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelIsRemoved.cs index b0a6c863..829b009f 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelIsRemoved.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenChangingParcelGeometry/GivenParcelIsRemoved.cs @@ -1,19 +1,12 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenChangingParcelGeometry { - using System.Collections.Generic; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using ParcelRegistry.Api.BackOffice.Abstractions.Extensions; - using ParcelRegistry.Parcel; - using ParcelRegistry.Parcel.Commands; - using ParcelRegistry.Parcel.Events; - using ParcelRegistry.Parcel.Exceptions; - using ParcelRegistry.Tests.Fixtures; + using Builders; + using Fixtures; + using Parcel; + using Parcel.Exceptions; using Xunit; using Xunit.Abstractions; - using ParcelId = ParcelRegistry.Legacy.ParcelId; - using ParcelStatus = Parcel.ParcelStatus; public class GivenParcelIsRemoved : ParcelRegistryTest { @@ -27,21 +20,14 @@ public GivenParcelIsRemoved(ITestOutputHelper testOutputHelper) : base(testOutpu [Fact] public void ThenThrowParcelIsRemovedException() { - var command = new ChangeParcelGeometry( - Fixture.Create(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), - new List(), - Fixture.Create()); + var command = new ChangeParcelGeometryBuilder(Fixture) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Retired, - isRemoved: true, - new List(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Retired) + .WithIsRemoved() + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAlreadyDetached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAlreadyDetached.cs index 9e321ff0..7dcb39fa 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAlreadyDetached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAlreadyDetached.cs @@ -1,14 +1,9 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingAddressBecauseAddressWasRejected { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using Parcel; - using Parcel.Commands; - using Parcel.Events; + using Builders; using Fixtures; + using Parcel; using Xunit; using Xunit.Abstractions; @@ -26,24 +21,14 @@ public void ThenNothing() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddressBecauseAddressWasRejected( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBecauseAddressWasRejectedBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Realized) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAttached.cs index b5e046b2..784d6a80 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRejected/GivenAddressAttached.cs @@ -1,25 +1,22 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingAddressBecauseAddressWasRejected { using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using FluentAssertions; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressAttached : ParcelRegistryTest { @@ -35,25 +32,15 @@ public void ThenAddressWasDetachedBecauseAddressWasRemoved() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddressBecauseAddressWasRejected( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBecauseAddressWasRejectedBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - command.AddressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Realized) + .WithAddress(command.AddressPersistentLocalId) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( @@ -77,30 +64,22 @@ public void StateCheck() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - Fixture.Create(), - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - addressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(addressPersistentLocalId) + .WithAddress(456) + .Build(); - var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedBecauseAddressWasRejected(Fixture.Create(), new VbrCaPaKey(parcelWasMigrated.CaPaKey), addressPersistentLocalId); - ((ISetProvenance)parcelAddressWasDetachedV2).SetProvenance(Fixture.Create()); + var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); // Act var sut = new ParcelFactory(NoSnapshotStrategy.Instance, Container.Resolve()).Create(); sut.Initialize(new List { parcelWasMigrated, parcelAddressWasDetachedV2 }); // Assert - sut.AddressPersistentLocalIds.Should().HaveCount(2); + sut.AddressPersistentLocalIds.Should().HaveCount(1); sut.AddressPersistentLocalIds.Should().NotContain(addressPersistentLocalId); sut.LastEventHash.Should().Be(parcelAddressWasDetachedV2.GetHash()); } diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAlreadyDetached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAlreadyDetached.cs index 5d62f87a..5692e54c 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAlreadyDetached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAlreadyDetached.cs @@ -1,14 +1,9 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingAddressBecauseAddressWasRemoved { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using Parcel; - using Parcel.Commands; - using Parcel.Events; + using Builders; using Fixtures; + using Parcel; using Xunit; using Xunit.Abstractions; @@ -26,24 +21,13 @@ public void ThenNothing() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddressBecauseAddressWasRemoved( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBecauseAddressWasRemovedBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAttached.cs index 4e7936e3..d5d3fba4 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRemoved/GivenAddressAttached.cs @@ -1,25 +1,22 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingAddressBecauseAddressWasRemoved { using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using FluentAssertions; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressAttached : ParcelRegistryTest { @@ -35,25 +32,14 @@ public void ThenAddressWasDetachedBecauseAddressWasRemoved() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddressBecauseAddressWasRemoved( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBecauseAddressWasRemovedBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - command.AddressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithAddress(addressPersistentLocalId) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( @@ -77,30 +63,23 @@ public void StateCheck() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - Fixture.Create(), - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - addressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(addressPersistentLocalId) + .WithAddress(456) + .Build(); + + var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedBecauseAddressWasRemoved(Fixture.Create(), new VbrCaPaKey(parcelWasMigrated.CaPaKey), addressPersistentLocalId); - ((ISetProvenance)parcelAddressWasDetachedV2).SetProvenance(Fixture.Create()); // Act var sut = new ParcelFactory(NoSnapshotStrategy.Instance, Container.Resolve()).Create(); sut.Initialize(new List { parcelWasMigrated, parcelAddressWasDetachedV2 }); // Assert - sut.AddressPersistentLocalIds.Should().HaveCount(2); + sut.AddressPersistentLocalIds.Should().HaveCount(1); sut.AddressPersistentLocalIds.Should().NotContain(addressPersistentLocalId); sut.LastEventHash.Should().Be(parcelAddressWasDetachedV2.GetHash()); } diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAlreadyDetached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAlreadyDetached.cs index a9cf8eeb..24018f0f 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAlreadyDetached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAlreadyDetached.cs @@ -1,14 +1,9 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingAddressBecauseAddressWasRetired { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using Parcel; - using Parcel.Commands; - using Parcel.Events; + using Builders; using Fixtures; + using Parcel; using Xunit; using Xunit.Abstractions; @@ -24,26 +19,13 @@ public GivenAddressAlreadyDetached(ITestOutputHelper testOutputHelper) : base(te [Fact] public void ThenNothing() { - var addressPersistentLocalId = new AddressPersistentLocalId(123); - - var command = new DetachAddressBecauseAddressWasRetired( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBecauseAddressWasRetiredBuilder(Fixture) + .WithAddress(1) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAttached.cs index 6363fbcd..3b79a43a 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingAddressBecauseAddressWasRetired/GivenAddressAttached.cs @@ -1,25 +1,22 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingAddressBecauseAddressWasRetired { using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using FluentAssertions; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressAttached : ParcelRegistryTest { @@ -35,25 +32,14 @@ public void ThenAddressWasDetachedBecauseAddressWasRemoved() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddressBecauseAddressWasRetired( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBecauseAddressWasRetiredBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - command.AddressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithAddress(addressPersistentLocalId) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( @@ -77,30 +63,22 @@ public void StateCheck() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - Fixture.Create(), - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - addressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(addressPersistentLocalId) + .WithAddress(456) + .Build(); - var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedBecauseAddressWasRetired(Fixture.Create(), new VbrCaPaKey(parcelWasMigrated.CaPaKey), addressPersistentLocalId); - ((ISetProvenance)parcelAddressWasDetachedV2).SetProvenance(Fixture.Create()); + var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); // Act var sut = new ParcelFactory(NoSnapshotStrategy.Instance, Container.Resolve()).Create(); sut.Initialize(new List { parcelWasMigrated, parcelAddressWasDetachedV2 }); // Assert - sut.AddressPersistentLocalIds.Should().HaveCount(2); + sut.AddressPersistentLocalIds.Should().HaveCount(1); sut.AddressPersistentLocalIds.Should().NotContain(addressPersistentLocalId); sut.LastEventHash.Should().Be(parcelAddressWasDetachedV2.GetHash()); } diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAlreadyDetached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAlreadyDetached.cs index e657d0f0..fcda6fa9 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAlreadyDetached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAlreadyDetached.cs @@ -1,22 +1,17 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingParcelAddress { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressAlreadyDetached : ParcelRegistryTest { @@ -32,24 +27,12 @@ public void ThenNothing() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAttached.cs index e891ab93..5efd7f1c 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenAddressAttached.cs @@ -1,25 +1,22 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingParcelAddress { using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using FluentAssertions; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenAddressAttached : ParcelRegistryTest { @@ -35,25 +32,14 @@ public void ThenParcelAddressWasDetachedV2() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - command.AddressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(addressPersistentLocalId) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( @@ -77,30 +63,22 @@ public void StateCheck() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - Fixture.Create(), - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - addressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(addressPersistentLocalId) + .WithAddress(456) + .Build(); - var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedV2(Fixture.Create(), new VbrCaPaKey(parcelWasMigrated.CaPaKey), addressPersistentLocalId); - ((ISetProvenance)parcelAddressWasDetachedV2).SetProvenance(Fixture.Create()); + var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedV2Builder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); // Act var sut = new ParcelFactory(NoSnapshotStrategy.Instance, Container.Resolve()).Create(); sut.Initialize(new List { parcelWasMigrated, parcelAddressWasDetachedV2 }); // Assert - sut.AddressPersistentLocalIds.Should().HaveCount(2); + sut.AddressPersistentLocalIds.Should().HaveCount(1); sut.AddressPersistentLocalIds.Should().NotContain(addressPersistentLocalId); sut.LastEventHash.Should().Be(parcelAddressWasDetachedV2.GetHash()); } diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenParcelIsRemoved.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenParcelIsRemoved.cs index 699d6598..6fce8f12 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenParcelIsRemoved.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenDetachingParcelAddress/GivenParcelIsRemoved.cs @@ -1,23 +1,18 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenDetachingParcelAddress { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; using AutoFixture; using BackOffice; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; using Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor; + using Builders; using Consumer.Address; using Fixtures; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; - using Parcel.Events; using Parcel.Exceptions; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; public class GivenParcelIsRemoved : ParcelRegistryTest { @@ -33,25 +28,15 @@ public void ThenThrowParcelIsRemovedException() { var addressPersistentLocalId = new AddressPersistentLocalId(123); - var command = new DetachAddress( - Fixture.Create(), - addressPersistentLocalId, - Fixture.Create()); + var command = new DetachAddressBuilder(Fixture) + .WithAddress(addressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Retired, - isRemoved: true, - new List - { - addressPersistentLocalId, - new AddressPersistentLocalId(456), - new AddressPersistentLocalId(789), - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Retired) + .WithIsRemoved() + .WithAddress(addressPersistentLocalId) + .Build(); var consumerAddress = Container.Resolve(); consumerAddress.AddAddress( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelDoesNotExists.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelDoesNotExists.cs index 8e2e7322..035fdd10 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelDoesNotExists.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelDoesNotExists.cs @@ -6,6 +6,7 @@ using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using EventExtensions; using Fixtures; using FluentAssertions; @@ -27,27 +28,30 @@ public void ThenParcelImported() { var caPaKey = Fixture.Create(); - var command = new ImportParcel( - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), - new List() - { - new AddressPersistentLocalId(1), - new AddressPersistentLocalId(2) - }, - Fixture.Create()); - + var command = new ImportParcelBuilder(Fixture) + .WithCaPaKey(caPaKey) + .WithAddress(1) + .WithAddress(2) + .Build(); + Assert(new Scenario() + .Given(new ParcelStreamId(command.ParcelId)) + .When(command) + .Then(new ParcelStreamId(command.ParcelId), + new ParcelWasImported( + command.ParcelId, + caPaKey, + command.ExtendedWkbGeometry), + new ParcelAddressWasAttachedV2(command.ParcelId, caPaKey, new AddressPersistentLocalId(1)), + new ParcelAddressWasAttachedV2(command.ParcelId, caPaKey, new AddressPersistentLocalId(2)))); } [Fact] public void WithInvalidPolygon_ThenThrowsPolygonIsInvalidException() { - var command = new ImportParcel( - Fixture.Create(), - GeometryHelpers.GmlPointGeometry.GmlToExtendedWkbGeometry(), - new List(), - Fixture.Create()); + var command = new ImportParcelBuilder(Fixture) + .WithExtendedWkbGeometry(GeometryHelpers.GmlPointGeometry.GmlToExtendedWkbGeometry()) + .Build(); Assert(new Scenario() .Given(new ParcelStreamId(command.ParcelId)) @@ -61,11 +65,10 @@ public void StateCheck() var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); var parcel = new ParcelFactory(NoSnapshotStrategy.Instance, new Mock().Object).Create(); parcel.Initialize(new object[] diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelExists.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelExists.cs index 465da146..3ee18fd7 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelExists.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenImportingParcel/GivenParcelExists.cs @@ -6,6 +6,7 @@ using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using EventExtensions; using Fixtures; using FluentAssertions; @@ -31,18 +32,10 @@ public GivenParcelExists(ITestOutputHelper testOutputHelper) : base(testOutputHe public void WithRealizedParcel_ThenThrowsParcelAlreadyExistsException() { var caPaKey = Fixture.Create(); - var legacyParcelId = ParcelRegistry.Legacy.ParcelId.CreateFor(caPaKey); - var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasMigrated = new ParcelWasMigrated( - legacyParcelId, - parcelId, - Fixture.Create(), - ParcelStatus.Realized, - false, - Fixture.Create>(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasMigrated.SetFixtureProvenance(Fixture); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); var command = new ImportParcel( caPaKey, @@ -60,18 +53,10 @@ public void WithRealizedParcel_ThenThrowsParcelAlreadyExistsException() public void WithRetiredParcel_ThenParcelRetirementWasCorrected() { var caPaKey = Fixture.Create(); - var legacyParcelId = ParcelRegistry.Legacy.ParcelId.CreateFor(caPaKey); - var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasMigrated = new ParcelWasMigrated( - legacyParcelId, - parcelId, - Fixture.Create(), - ParcelStatus.Retired, - false, - Fixture.Create>(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasMigrated.SetFixtureProvenance(Fixture); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Retired) + .Build(); var command = new ImportParcel( caPaKey, @@ -97,20 +82,20 @@ public void StateCheck() var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .Build(); - var parcelWasRetiredV2 = new ParcelWasRetiredV2(parcelId, caPaKey); - parcelWasRetiredV2.SetFixtureProvenance(Fixture); + var parcelWasRetiredV2 = new ParcelWasRetiredV2Builder(Fixture) + .WithParcelId(parcelId) + .WithVbrCaPaKey(caPaKey) + .Build(); - var parcelRetirementWasCorrected = new ParcelWasCorrectedFromRetiredToRealized( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry()); - parcelRetirementWasCorrected.SetFixtureProvenance(Fixture); + var parcelRetirementWasCorrected = new ParcelWasCorrectedFromRetiredToRealizedBuilder(Fixture) + .WithParcelId(parcelId) + .WithVbrCaPaKey(caPaKey) + .WithExtendedWkbGeometry(GeometryHelpers.ValidGmlPolygon2.GmlToExtendedWkbGeometry()) + .Build(); var parcel = new ParcelFactory(NoSnapshotStrategy.Instance, new Mock().Object).Create(); parcel.Initialize(new object[] diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelAlreadyExists.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelAlreadyExists.cs index b2760300..3ef30e3b 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelAlreadyExists.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelAlreadyExists.cs @@ -1,16 +1,14 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenMigratingParcel { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; + using ParcelStatus = ParcelRegistry.Legacy.ParcelStatus; public class GivenParcelAlreadyExists : ParcelRegistryTest { @@ -22,14 +20,9 @@ public void ThenThrowInvalidOperationException() { var parcelWasMigrated = Fixture.Create(); - var command = new MigrateParcel( - Fixture.Create(), - Fixture.Create(), - ParcelRegistry.Legacy.ParcelStatus.Realized, - Fixture.Create(), - Fixture.Create>(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), - Fixture.Create()); + var command = new MigrateParcelBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelDoesNotExist.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelDoesNotExist.cs index 30ef1837..fc5a5718 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelDoesNotExist.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenMigratingParcel/GivenParcelDoesNotExist.cs @@ -1,22 +1,19 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenMigratingParcel { - using System.Collections.Generic; using Api.BackOffice.Abstractions.Extensions; using Autofac; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using FluentAssertions; using NetTopologySuite.Geometries; using Parcel; - using Parcel.Commands; using Parcel.Events; using Parcel.Exceptions; using Xunit; using Xunit.Abstractions; - using Coordinate = Parcel.Coordinate; + using ParcelStatus = ParcelRegistry.Legacy.ParcelStatus; public class GivenParcelDoesNotExist : ParcelRegistryTest { @@ -26,14 +23,9 @@ public GivenParcelDoesNotExist(ITestOutputHelper testOutputHelper) : base(testOu [Fact] public void ThenParcelWasMigratedEvent() { - var command = new MigrateParcel( - Fixture.Create(), - Fixture.Create(), - ParcelRegistry.Legacy.ParcelStatus.Realized, - Fixture.Create(), - Fixture.Create>(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), - Fixture.Create()); + var command = new MigrateParcelBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); Assert(new Scenario() .GivenNone() @@ -52,14 +44,9 @@ public void ThenParcelWasMigratedEvent() [Fact] public void WithValidMultiPolygon_ThenParcelWasMigratedEvent() { - var command = new MigrateParcel( - Fixture.Create(), - Fixture.Create(), - ParcelRegistry.Legacy.ParcelStatus.Realized, - Fixture.Create(), - Fixture.Create>(), - GeometryHelpers.ToExtendedWkbGeometry(new MultiPolygon(new[] {GeometryHelpers.ValidPolygon})), - Fixture.Create()); + var command = new MigrateParcelBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); Assert(new Scenario() .GivenNone() @@ -78,14 +65,10 @@ public void WithValidMultiPolygon_ThenParcelWasMigratedEvent() [Fact] public void WithInvalidPolygon_ThenThrowsPolygonIsInvalidException() { - var command = new MigrateParcel( - Fixture.Create(), - Fixture.Create(), - ParcelRegistry.Legacy.ParcelStatus.Realized, - Fixture.Create(), - Fixture.Create>(), - GeometryHelpers.GmlPointGeometry.GmlToExtendedWkbGeometry(), - Fixture.Create()); + var command = new MigrateParcelBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithExtendedWkbGeometry(GeometryHelpers.GmlPointGeometry.GmlToExtendedWkbGeometry()) + .Build(); Assert(new Scenario() .GivenNone() @@ -96,14 +79,10 @@ public void WithInvalidPolygon_ThenThrowsPolygonIsInvalidException() [Fact] public void WithInValidMultiPolygon_ThenParcelWasMigratedEvent() { - var command = new MigrateParcel( - Fixture.Create(), - Fixture.Create(), - ParcelRegistry.Legacy.ParcelStatus.Realized, - Fixture.Create(), - Fixture.Create>(), - GeometryHelpers.ToExtendedWkbGeometry(new MultiPolygon(new[] {GeometryHelpers.InValidPolygon})), - Fixture.Create()); + var command = new MigrateParcelBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithExtendedWkbGeometry(GeometryHelpers.ToExtendedWkbGeometry(new MultiPolygon(new[] { GeometryHelpers.InValidPolygon }))) + .Build(); Assert(new Scenario() .GivenNone() @@ -114,14 +93,9 @@ public void WithInValidMultiPolygon_ThenParcelWasMigratedEvent() [Fact] public void StateCheck() { - var command = new MigrateParcel( - Fixture.Create(), - Fixture.Create(), - ParcelRegistry.Legacy.ParcelStatus.Realized, - Fixture.Create(), - Fixture.Create>(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), - Fixture.Create()); + var command = new MigrateParcelBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .Build(); // Act var result = Parcel.MigrateParcel( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressAttached.cs index d7e3236a..1dd059ed 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressAttached.cs @@ -8,6 +8,7 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenReplacingAttachedAddressBecaus using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using Fixtures; using FluentAssertions; using Parcel; @@ -31,26 +32,17 @@ public void WithPreviousAddressAttached_ThenParcelAddressWasReplacedBecauseAddre var previousAddressPersistentLocalId = new AddressPersistentLocalId(1); var addressPersistentLocalId = new AddressPersistentLocalId(3); - var command = new ReplaceAttachedAddressBecauseAddressWasReaddressed( - Fixture.Create(), - addressPersistentLocalId, - previousAddressPersistentLocalId, - Fixture.Create()); + var command = new ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder(Fixture) + .WithNewAddress(addressPersistentLocalId) + .WithPreviousAddress(previousAddressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - previousAddressPersistentLocalId, - new AddressPersistentLocalId(2), - addressPersistentLocalId - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(previousAddressPersistentLocalId) + .WithAddress(2) + .WithAddress(addressPersistentLocalId) + .Build(); Assert(new Scenario() .Given( @@ -71,25 +63,16 @@ public void WithPreviousAddressNotAttached_ThenNothing() var previousAddressPersistentLocalId = new AddressPersistentLocalId(1); var addressPersistentLocalId = new AddressPersistentLocalId(3); - var command = new ReplaceAttachedAddressBecauseAddressWasReaddressed( - Fixture.Create(), - addressPersistentLocalId, - previousAddressPersistentLocalId, - Fixture.Create()); + var command = new ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder(Fixture) + .WithNewAddress(addressPersistentLocalId) + .WithPreviousAddress(previousAddressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(2), - addressPersistentLocalId - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(2) + .WithAddress(addressPersistentLocalId) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressNotAttached.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressNotAttached.cs index c16bed6a..ff80fe10 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressNotAttached.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenReplacingAttachedAddressBecauseAddressWasReaddressed/GivenAddressNotAttached.cs @@ -1,17 +1,14 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenReplacingAttachedAddressBecauseAddressWasReaddressed { using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using Autofac; - using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using Fixtures; using FluentAssertions; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; @@ -31,25 +28,16 @@ public void WithPreviousAddressAttached_ThenParcelAddressWasReplacedBecauseAddre var previousAddressPersistentLocalId = new AddressPersistentLocalId(1); var addressPersistentLocalId = new AddressPersistentLocalId(3); - var command = new ReplaceAttachedAddressBecauseAddressWasReaddressed( - Fixture.Create(), - addressPersistentLocalId, - previousAddressPersistentLocalId, - Fixture.Create()); + var command = new ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder(Fixture) + .WithNewAddress(addressPersistentLocalId) + .WithPreviousAddress(previousAddressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - previousAddressPersistentLocalId, - new AddressPersistentLocalId(2) - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(previousAddressPersistentLocalId) + .WithAddress(2) + .Build(); Assert(new Scenario() .Given( @@ -70,24 +58,16 @@ public void WithPreviousAddressNotAttached_ThenParcelAddressWasReplacedBecauseAd var previousAddressPersistentLocalId = new AddressPersistentLocalId(1); var addressPersistentLocalId = new AddressPersistentLocalId(3); - var command = new ReplaceAttachedAddressBecauseAddressWasReaddressed( - Fixture.Create(), - addressPersistentLocalId, - previousAddressPersistentLocalId, - Fixture.Create()); + var command = new ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder(Fixture) + .WithNewAddress(addressPersistentLocalId) + .WithPreviousAddress(previousAddressPersistentLocalId) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - new AddressPersistentLocalId(2) - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Realized) + .WithAddress(2) + .Build(); Assert(new Scenario() .Given( @@ -109,27 +89,18 @@ public void StateCheck() var addressPersistentLocalId = new AddressPersistentLocalId(3); var otherAddressPersistentLocalId = new AddressPersistentLocalId(2); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - Fixture.Create(), - Fixture.Create(), - ParcelStatus.Realized, - isRemoved: false, - new List - { - previousAddressPersistentLocalId, - otherAddressPersistentLocalId, - }, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); - - var attachedParcelAddressWasReplacedBecauseAddressWasReaddressed = new ParcelAddressWasReplacedBecauseAddressWasReaddressed( - Fixture.Create(), - new VbrCaPaKey(parcelWasMigrated.CaPaKey), - addressPersistentLocalId, - previousAddressPersistentLocalId); - ((ISetProvenance)attachedParcelAddressWasReplacedBecauseAddressWasReaddressed).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithStatus(ParcelStatus.Realized) + .WithAddress(previousAddressPersistentLocalId) + .WithAddress(otherAddressPersistentLocalId) + .Build(); + var attachedParcelAddressWasReplacedBecauseAddressWasReaddressed = + new ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder(Fixture) + .WithVbrCaPaKey(new VbrCaPaKey(parcelWasMigrated.CaPaKey)) + .WithNewAddress(addressPersistentLocalId) + .WithPreviousAddress(previousAddressPersistentLocalId) + .Build(); // Act var sut = new ParcelFactory(NoSnapshotStrategy.Instance, Container.Resolve()).Create(); sut.Initialize(new List { parcelWasMigrated, attachedParcelAddressWasReplacedBecauseAddressWasReaddressed }); diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExists.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExists.cs index 536282aa..ce68a86e 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExists.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExists.cs @@ -1,12 +1,10 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenRetiringParcel { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using EventExtensions; + using Builders; using FluentAssertions; using Moq; using Parcel; @@ -23,30 +21,29 @@ public GivenParcelExists(ITestOutputHelper testOutputHelper) : base(testOutputHe } [Fact] - public void ThenParcelRetired() + public void ThenParcelIsRetired() { var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); var firstAddressPersistentLocalId = new AddressPersistentLocalId(1); - var firstParcelAddressWasAttached = new ParcelAddressWasAttachedV2( - parcelId, - caPaKey, - firstAddressPersistentLocalId); - firstParcelAddressWasAttached.SetFixtureProvenance(Fixture); + var firstParcelAddressWasAttached = new ParcelAddressWasAttachedV2Builder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .WithAddress(firstAddressPersistentLocalId) + .Build(); var secondAddressPersistentLocalId = new AddressPersistentLocalId(2); - var secondParcelAddressWasAttached = new ParcelAddressWasAttachedV2( - parcelId, - caPaKey, - secondAddressPersistentLocalId); - secondParcelAddressWasAttached.SetFixtureProvenance(Fixture); + var secondParcelAddressWasAttached = new ParcelAddressWasAttachedV2Builder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .WithAddress(secondAddressPersistentLocalId) + .Build(); var command = new RetireParcelV2(caPaKey, Fixture.Create()); @@ -63,22 +60,17 @@ public void ThenParcelRetired() } [Fact] - public void WhenAlreadyRetired_ThenNone() + public void WithRetiredParcel_ThenNone() { var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); var command = new RetireParcelV2(caPaKey, Fixture.Create()); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Retired, - isRemoved: false, - new List(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithStatus(ParcelStatus.Retired) + .Build(); Assert(new Scenario() .Given(new ParcelStreamId(parcelId), parcelWasMigrated) @@ -92,14 +84,15 @@ public void StateCheck() var parcelId = Fixture.Create(); var caPaKey = Fixture.Create(); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - Fixture.Create()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); - var parcelWasRetiredV2 = new ParcelWasRetiredV2(parcelId, caPaKey); - parcelWasRetiredV2.SetFixtureProvenance(Fixture); + var parcelWasRetiredV2 = new ParcelWasRetiredV2Builder(Fixture) + .WithParcelId(parcelId) + .WithVbrCaPaKey(caPaKey) + .Build(); var parcel = new ParcelFactory(NoSnapshotStrategy.Instance, new Mock().Object).Create(); parcel.Initialize(new object[] diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExistsWithAttachedAddresses.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExistsWithAttachedAddresses.cs index e9a3e404..ff81c104 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExistsWithAttachedAddresses.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelExistsWithAttachedAddresses.cs @@ -1,17 +1,10 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenRetiringParcel { - using System.Collections.Generic; - using Api.BackOffice.Abstractions.Extensions; using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource; - using Be.Vlaanderen.Basisregisters.AggregateSource.Snapshotting; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using EventExtensions; - using FluentAssertions; - using Moq; + using Builders; using Parcel; - using Parcel.Commands; using Parcel.Events; using Xunit; using Xunit.Abstractions; @@ -29,17 +22,21 @@ public void ThenParcelRetiredAndAddressesDetached() var caPaKey = Fixture.Create(); var parcelId = ParcelId.CreateFor(caPaKey); - var parcelWasImported = new ParcelWasImported( - parcelId, - caPaKey, - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - parcelWasImported.SetFixtureProvenance(Fixture); + var parcelWasImported = new ParcelWasImportedBuilder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .Build(); var attachedAddressPersistentLocalId = Fixture.Create(); - var addressWasAttached = new ParcelAddressWasAttachedV2(parcelId, caPaKey, attachedAddressPersistentLocalId); - addressWasAttached.SetFixtureProvenance(Fixture); + var addressWasAttached = new ParcelAddressWasAttachedV2Builder(Fixture) + .WithParcelId(parcelId) + .WithCaPaKey(caPaKey) + .WithAddress(attachedAddressPersistentLocalId) + .Build(); - var command = new RetireParcelV2(caPaKey, Fixture.Create()); + var command = new RetireParcelV2Builder(Fixture) + .WithVbrCaPaKey(caPaKey) + .Build(); Assert(new Scenario() .Given(new ParcelStreamId(parcelId), parcelWasImported, addressWasAttached) diff --git a/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelIsRemoved.cs b/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelIsRemoved.cs index 5d7590e4..65eece86 100644 --- a/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelIsRemoved.cs +++ b/test/ParcelRegistry.Tests/AggregateTests/WhenRetiringParcel/GivenParcelIsRemoved.cs @@ -5,6 +5,7 @@ namespace ParcelRegistry.Tests.AggregateTests.WhenRetiringParcel using AutoFixture; using Be.Vlaanderen.Basisregisters.AggregateSource.Testing; using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Builders; using Fixtures; using Parcel; using Parcel.Commands; @@ -27,19 +28,14 @@ public GivenParcelIsRemoved(ITestOutputHelper testOutputHelper) : base(testOutpu [Fact] public void ThenThrowParcelIsRemovedException() { - var command = new RetireParcelV2( - Fixture.Create(), - Fixture.Create()); + var command = new RetireParcelV2Builder(Fixture) + .Build(); - var parcelWasMigrated = new ParcelWasMigrated( - Fixture.Create(), - command.ParcelId, - Fixture.Create(), - ParcelStatus.Retired, - isRemoved: true, - new List(), - GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); - ((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create()); + var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture) + .WithParcelId(command.ParcelId) + .WithIsRemoved() + .WithStatus(ParcelStatus.Retired) + .Build(); Assert(new Scenario() .Given( diff --git a/test/ParcelRegistry.Tests/Builders/AttachAddressBuilder.cs b/test/ParcelRegistry.Tests/Builders/AttachAddressBuilder.cs new file mode 100644 index 00000000..aa847618 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/AttachAddressBuilder.cs @@ -0,0 +1,43 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + public class AttachAddressBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public AttachAddressBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public AttachAddressBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public AttachAddressBuilder WithAddress(int persistentLocalId) + { + _addressPersistentLocalId = new AddressPersistentLocalId(persistentLocalId); + + return this; + } + + public AttachAddress Build() + { + var attachAddress = new AttachAddress( + _parcelId ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create(), + _fixture.Create()); + + return attachAddress; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ChangeParcelGeometryBuilder.cs b/test/ParcelRegistry.Tests/Builders/ChangeParcelGeometryBuilder.cs new file mode 100644 index 00000000..a1a0eea5 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ChangeParcelGeometryBuilder.cs @@ -0,0 +1,57 @@ +namespace ParcelRegistry.Tests.Builders +{ + using System.Collections.Generic; + using Api.BackOffice.Abstractions.Extensions; + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + /// + /// Builder for creating instances of ChangeParcelGeometryBuilder. + /// By default, the ExtendedWkbGeometry is a valid GmlPolygon. + /// + public class ChangeParcelGeometryBuilder + { + private readonly Fixture _fixture; + private VbrCaPaKey? _vbrCaPaKey; + private ExtendedWkbGeometry? _extendedWkbGeometry; + private List _addressPersistentLocalIds; + + public ChangeParcelGeometryBuilder(Fixture fixture) + { + _fixture = fixture; + _addressPersistentLocalIds = new List(); + } + + public ChangeParcelGeometryBuilder WithVbrCaPaKey(VbrCaPaKey caPaKey) + { + _vbrCaPaKey = caPaKey; + + return this; + } + + public ChangeParcelGeometryBuilder WithExtendedWkbGeometry(ExtendedWkbGeometry extendedWkbGeometry) + { + _extendedWkbGeometry = extendedWkbGeometry; + + return this; + } + + public ChangeParcelGeometryBuilder WithAddress(int address) + { + _addressPersistentLocalIds.Add(new AddressPersistentLocalId(address)); + + return this; + } + + public ChangeParcelGeometry Build() + { + return new ChangeParcelGeometry( + _vbrCaPaKey ?? _fixture.Create(), + _extendedWkbGeometry ?? GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), + _addressPersistentLocalIds, + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRejectedBuilder.cs b/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRejectedBuilder.cs new file mode 100644 index 00000000..aa6aa516 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRejectedBuilder.cs @@ -0,0 +1,41 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + public class DetachAddressBecauseAddressWasRejectedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public DetachAddressBecauseAddressWasRejectedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public DetachAddressBecauseAddressWasRejectedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public DetachAddressBecauseAddressWasRejectedBuilder WithAddress(int addressPersistentLocalId) + { + _addressPersistentLocalId = new AddressPersistentLocalId(addressPersistentLocalId); + + return this; + } + + public DetachAddressBecauseAddressWasRejected Build() + { + return new DetachAddressBecauseAddressWasRejected( + _parcelId ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create(), + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRemovedBuilder.cs b/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRemovedBuilder.cs new file mode 100644 index 00000000..2d7de8ef --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRemovedBuilder.cs @@ -0,0 +1,41 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + public class DetachAddressBecauseAddressWasRemovedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public DetachAddressBecauseAddressWasRemovedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public DetachAddressBecauseAddressWasRemovedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public DetachAddressBecauseAddressWasRemovedBuilder WithAddress(int addressPersistentLocalId) + { + _addressPersistentLocalId = new AddressPersistentLocalId(addressPersistentLocalId); + + return this; + } + + public DetachAddressBecauseAddressWasRemoved Build() + { + return new DetachAddressBecauseAddressWasRemoved( + _parcelId ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create(), + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRetiredBuilder.cs b/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRetiredBuilder.cs new file mode 100644 index 00000000..7cd84387 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/DetachAddressBecauseAddressWasRetiredBuilder.cs @@ -0,0 +1,41 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + public class DetachAddressBecauseAddressWasRetiredBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public DetachAddressBecauseAddressWasRetiredBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public DetachAddressBecauseAddressWasRetiredBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public DetachAddressBecauseAddressWasRetiredBuilder WithAddress(int addressPersistentLocalId) + { + _addressPersistentLocalId = new AddressPersistentLocalId(addressPersistentLocalId); + + return this; + } + + public DetachAddressBecauseAddressWasRetired Build() + { + return new DetachAddressBecauseAddressWasRetired( + _parcelId ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create(), + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/DetachAddressBuilder.cs b/test/ParcelRegistry.Tests/Builders/DetachAddressBuilder.cs new file mode 100644 index 00000000..791f6b5b --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/DetachAddressBuilder.cs @@ -0,0 +1,41 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + public class DetachAddressBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public DetachAddressBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public DetachAddressBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public DetachAddressBuilder WithAddress(int addressPersistentLocalId) + { + _addressPersistentLocalId = new AddressPersistentLocalId(addressPersistentLocalId); + + return this; + } + + public DetachAddress Build() + { + return new DetachAddress( + _parcelId ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create(), + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ImportParcelBuilder.cs b/test/ParcelRegistry.Tests/Builders/ImportParcelBuilder.cs new file mode 100644 index 00000000..07fb266f --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ImportParcelBuilder.cs @@ -0,0 +1,57 @@ +namespace ParcelRegistry.Tests.Builders +{ + using System.Collections.Generic; + using Api.BackOffice.Abstractions.Extensions; + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + /// + /// Builder for creating instances of ImportParcelBuilderBuilder + /// By default, the ExtendedWkbGeometry is a valid GmlPolygon. + /// + public class ImportParcelBuilder + { + private readonly Fixture _fixture; + private VbrCaPaKey? _caPaKey; + private ExtendedWkbGeometry? _extendedWkbGeometry; + private List _addressPersistentLocalIds; + + public ImportParcelBuilder(Fixture fixture) + { + _fixture = fixture; + _addressPersistentLocalIds = new List(); + } + + public ImportParcelBuilder WithAddress(int addressPersistentLocalId) + { + _addressPersistentLocalIds.Add(new AddressPersistentLocalId(addressPersistentLocalId)); + + return this; + } + + public ImportParcelBuilder WithCaPaKey(VbrCaPaKey caPaKey) + { + _caPaKey = caPaKey; + + return this; + } + + public ImportParcelBuilder WithExtendedWkbGeometry(ExtendedWkbGeometry extendedWkbGeometry) + { + _extendedWkbGeometry = extendedWkbGeometry; + + return this; + } + + public ImportParcel Build() + { + return new ImportParcel( + _caPaKey ?? _fixture.Create(), + _extendedWkbGeometry ?? GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), + _addressPersistentLocalIds, + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/MigrateParcelBuilder.cs b/test/ParcelRegistry.Tests/Builders/MigrateParcelBuilder.cs new file mode 100644 index 00000000..c26d95d1 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/MigrateParcelBuilder.cs @@ -0,0 +1,86 @@ +namespace ParcelRegistry.Tests.Builders +{ + using System.Collections.Generic; + using Api.BackOffice.Abstractions.Extensions; + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + using ParcelId = ParcelRegistry.Legacy.ParcelId; + using ParcelStatus = ParcelRegistry.Legacy.ParcelStatus; + + /// + /// Builder for creating instances of MigrateParcelBuilder. + /// By default, the ExtendedWkbGeometry is a valid GmlPolygon. + /// + public class MigrateParcelBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _caPaKey; + private ParcelStatus? _status; + private bool _isRemoved; + private readonly List _addressPersistentLocalIds; + private ExtendedWkbGeometry? _extendedWkbGeometry; + + public MigrateParcelBuilder(Fixture fixture) + { + _fixture = fixture; + _addressPersistentLocalIds = new List(); + } + + public MigrateParcelBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public MigrateParcelBuilder WithCaPaKey(VbrCaPaKey caPaKey) + { + _caPaKey = caPaKey; + + return this; + } + + public MigrateParcelBuilder WithStatus(ParcelStatus status) + { + _status = status; + + return this; + } + + public MigrateParcelBuilder WithIsRemoved() + { + _isRemoved = true; + + return this; + } + + public MigrateParcelBuilder WithAddress(int persistentLocalId) + { + _addressPersistentLocalIds.Add(new AddressPersistentLocalId(persistentLocalId)); + + return this; + } + + public MigrateParcelBuilder WithExtendedWkbGeometry(ExtendedWkbGeometry extendedWkbGeometry) + { + _extendedWkbGeometry = extendedWkbGeometry; + + return this; + } + + public MigrateParcel Build() + { + return new MigrateParcel( + _parcelId ?? _fixture.Create(), + _caPaKey ?? _fixture.Create(), + _status ?? _fixture.Create(), + _isRemoved, + _addressPersistentLocalIds, + _extendedWkbGeometry ?? GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry(), + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelAddressWasAttachedV2Builder.cs b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasAttachedV2Builder.cs new file mode 100644 index 00000000..844bcb52 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasAttachedV2Builder.cs @@ -0,0 +1,53 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelAddressWasAttachedV2Builder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + private AddressPersistentLocalId? _address; + + public ParcelAddressWasAttachedV2Builder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelAddressWasAttachedV2Builder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelAddressWasAttachedV2Builder WithCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelAddressWasAttachedV2Builder WithAddress(int addressPersistentLocalId) + { + _address = new AddressPersistentLocalId(addressPersistentLocalId); + + return this; + } + + public ParcelAddressWasAttachedV2 Build() + { + var parcelAddressWasAttachedV2 = new ParcelAddressWasAttachedV2( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _address ?? _fixture.Create()); + + parcelAddressWasAttachedV2.SetFixtureProvenance(_fixture); + + return parcelAddressWasAttachedV2; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder.cs b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder.cs new file mode 100644 index 00000000..d4f0f862 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder.cs @@ -0,0 +1,52 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRejectedBuilder WithAddress(int address) + { + _addressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRejected Build() + { + var parcelAddressWasDetachedBecauseAddressWasRejected = new ParcelAddressWasDetachedBecauseAddressWasRejected( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create()); + parcelAddressWasDetachedBecauseAddressWasRejected.SetFixtureProvenance(_fixture); + + return parcelAddressWasDetachedBecauseAddressWasRejected; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder.cs b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder.cs new file mode 100644 index 00000000..208edbb9 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder.cs @@ -0,0 +1,52 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRemovedBuilder WithAddress(int address) + { + _addressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRemoved Build() + { + var parcelAddressWasDetachedBecauseAddressWasRemoved = new ParcelAddressWasDetachedBecauseAddressWasRemoved( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create()); + parcelAddressWasDetachedBecauseAddressWasRemoved.SetFixtureProvenance(_fixture); + + return parcelAddressWasDetachedBecauseAddressWasRemoved; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder.cs b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder.cs new file mode 100644 index 00000000..d348f345 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder.cs @@ -0,0 +1,52 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRetiredBuilder WithAddress(int address) + { + _addressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ParcelAddressWasDetachedBecauseAddressWasRetired Build() + { + var parcelAddressWasDetachedBecauseAddressWasRetired = new ParcelAddressWasDetachedBecauseAddressWasRetired( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create()); + parcelAddressWasDetachedBecauseAddressWasRetired.SetFixtureProvenance(_fixture); + + return parcelAddressWasDetachedBecauseAddressWasRetired; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedV2Builder.cs b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedV2Builder.cs new file mode 100644 index 00000000..d560063b --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasDetachedV2Builder.cs @@ -0,0 +1,52 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelAddressWasDetachedV2Builder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + private AddressPersistentLocalId? _addressPersistentLocalId; + + public ParcelAddressWasDetachedV2Builder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelAddressWasDetachedV2Builder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelAddressWasDetachedV2Builder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelAddressWasDetachedV2Builder WithAddress(int address) + { + _addressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ParcelAddressWasDetachedV2 Build() + { + var parcelAddressWasDetachedV2 = new ParcelAddressWasDetachedV2( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _addressPersistentLocalId ?? _fixture.Create()); + parcelAddressWasDetachedV2.SetFixtureProvenance(_fixture); + + return parcelAddressWasDetachedV2; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder.cs b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder.cs new file mode 100644 index 00000000..a0883a57 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder.cs @@ -0,0 +1,62 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private AddressPersistentLocalId? _newAddressPersistentLocalId; + private AddressPersistentLocalId? _previousAddressPersistentLocalId; + private VbrCaPaKey? _vbrCaPaKey; + + public ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder WithNewAddress(int address) + { + _newAddressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ParcelAddressWasReplacedBecauseAddressWasReaddressedBuilder WithPreviousAddress(int address) + { + _previousAddressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ParcelAddressWasReplacedBecauseAddressWasReaddressed Build() + { + var parcelAddressWasReplacedBecauseAddressWasReaddressed = new ParcelAddressWasReplacedBecauseAddressWasReaddressed( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _newAddressPersistentLocalId ?? _fixture.Create(), + _previousAddressPersistentLocalId ?? _fixture.Create()); + + parcelAddressWasReplacedBecauseAddressWasReaddressed.SetFixtureProvenance(_fixture); + + return parcelAddressWasReplacedBecauseAddressWasReaddressed; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelGeometryWasChangedBuilder.cs b/test/ParcelRegistry.Tests/Builders/ParcelGeometryWasChangedBuilder.cs new file mode 100644 index 00000000..2f4d7185 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelGeometryWasChangedBuilder.cs @@ -0,0 +1,57 @@ +namespace ParcelRegistry.Tests.Builders +{ + using Api.BackOffice.Abstractions.Extensions; + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + /// + /// Builder for creating instances of ParcelGeometryWasChangedBuilder. + /// By default, the ExtendedWkbGeometry is a valid GmlPolygon. + /// + public class ParcelGeometryWasChangedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + private ExtendedWkbGeometry? _extendedWkbGeometry; + + public ParcelGeometryWasChangedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelGeometryWasChangedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelGeometryWasChangedBuilder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelGeometryWasChangedBuilder WithExtendedWkbGeometry(ExtendedWkbGeometry extendedWkbGeometry) + { + _extendedWkbGeometry = extendedWkbGeometry; + + return this; + } + + public ParcelGeometryWasChanged Build() + { + var parcelGeometryWasChanged = new ParcelGeometryWasChanged( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _extendedWkbGeometry ?? GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); + parcelGeometryWasChanged.SetFixtureProvenance(_fixture); + + return parcelGeometryWasChanged; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelWasCorrectedFromRetiredToRealizedBuilder.cs b/test/ParcelRegistry.Tests/Builders/ParcelWasCorrectedFromRetiredToRealizedBuilder.cs new file mode 100644 index 00000000..82985e60 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelWasCorrectedFromRetiredToRealizedBuilder.cs @@ -0,0 +1,53 @@ +namespace ParcelRegistry.Tests.Builders +{ + using Api.BackOffice.Abstractions.Extensions; + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelWasCorrectedFromRetiredToRealizedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + private ExtendedWkbGeometry? _extendedWkbGeometry; + + public ParcelWasCorrectedFromRetiredToRealizedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelWasCorrectedFromRetiredToRealizedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelWasCorrectedFromRetiredToRealizedBuilder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelWasCorrectedFromRetiredToRealizedBuilder WithExtendedWkbGeometry(ExtendedWkbGeometry extendedWkbGeometry) + { + _extendedWkbGeometry = extendedWkbGeometry; + + return this; + } + + public ParcelWasCorrectedFromRetiredToRealized Build() + { + var parcelWasCorrectedFromRetiredToRealized = new ParcelWasCorrectedFromRetiredToRealized( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create(), + _extendedWkbGeometry ?? GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); + parcelWasCorrectedFromRetiredToRealized.SetFixtureProvenance(_fixture); + + return parcelWasCorrectedFromRetiredToRealized; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelWasImported.cs b/test/ParcelRegistry.Tests/Builders/ParcelWasImported.cs new file mode 100644 index 00000000..800c7a8e --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelWasImported.cs @@ -0,0 +1,57 @@ +namespace ParcelRegistry.Tests.Builders +{ + using Api.BackOffice.Abstractions.Extensions; + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + /// + /// Builder for creating instances of ParcelWasImportedBuilder. + /// By default, the ExtendedWkbGeometry is a valid GmlPolygon. + /// + public class ParcelWasImportedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _caPaKey; + private ExtendedWkbGeometry? _extendedWkbGeometry; + + public ParcelWasImportedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelWasImportedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelWasImportedBuilder WithCaPaKey(VbrCaPaKey caPaKey) + { + _caPaKey = caPaKey; + + return this; + } + + public ParcelWasImportedBuilder WithExtendedWkbGeometry(ExtendedWkbGeometry extendedWkbGeometry) + { + _extendedWkbGeometry = extendedWkbGeometry; + + return this; + } + + public ParcelWasImported Build() + { + var parcelWasImported = new ParcelWasImported( + _parcelId ?? _fixture.Create(), + _caPaKey ?? _fixture.Create(), + _extendedWkbGeometry ?? GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); + parcelWasImported.SetFixtureProvenance(_fixture); + + return parcelWasImported; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelWasMigratedBuilder.cs b/test/ParcelRegistry.Tests/Builders/ParcelWasMigratedBuilder.cs new file mode 100644 index 00000000..7d65d2ab --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelWasMigratedBuilder.cs @@ -0,0 +1,96 @@ +namespace ParcelRegistry.Tests.Builders +{ + using System.Collections.Generic; + using Api.BackOffice.Abstractions.Extensions; + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + /// + /// Builder for creating instances of ParcelWasMigrated. + /// By default, the ExtendedWkbGeometry is a valid GmlPolygon. + /// + public class ParcelWasMigratedBuilder + { + private readonly Fixture _fixture; + private ParcelRegistry.Legacy.ParcelId? _oldParcelId; + private ParcelId? _parcelId; + private VbrCaPaKey? _caPaKey; + private ParcelStatus? _status; + private bool _isRemoved; + private List _addressPersistentLocalIds; + private ExtendedWkbGeometry? _extendedWkbGeometry; + + public ParcelWasMigratedBuilder(Fixture fixture) + { + _fixture = fixture; + _addressPersistentLocalIds = new List(); + } + + public ParcelWasMigratedBuilder WithOldParcelId(ParcelRegistry.Legacy.ParcelId parcelId) + { + _oldParcelId = parcelId; + + return this; + } + + public ParcelWasMigratedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelWasMigratedBuilder WithCaPaKey(VbrCaPaKey caPaKey) + { + _caPaKey = caPaKey; + + return this; + } + + public ParcelWasMigratedBuilder WithStatus(ParcelStatus status) + { + _status = status; + + return this; + } + + public ParcelWasMigratedBuilder WithIsRemoved() + { + _isRemoved = true; + + return this; + } + + public ParcelWasMigratedBuilder WithAddress(int persistentLocalId) + { + _addressPersistentLocalIds.Add(new AddressPersistentLocalId(persistentLocalId)); + + return this; + } + + public ParcelWasMigratedBuilder WithExtendedWkbGeometry(ExtendedWkbGeometry extendedWkbGeometry) + { + _extendedWkbGeometry = extendedWkbGeometry; + + return this; + } + + public ParcelWasMigrated Build() + { + var parcelWasMigrated = new ParcelWasMigrated( + _oldParcelId ?? _fixture.Create(), + _parcelId ?? _fixture.Create(), + _caPaKey ?? _fixture.Create(), + _status ?? _fixture.Create(), + _isRemoved, + _addressPersistentLocalIds, + _extendedWkbGeometry ?? GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry()); + + parcelWasMigrated.SetFixtureProvenance(_fixture); + + return parcelWasMigrated; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ParcelWasRetiredV2Builder.cs b/test/ParcelRegistry.Tests/Builders/ParcelWasRetiredV2Builder.cs new file mode 100644 index 00000000..214d2c1f --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ParcelWasRetiredV2Builder.cs @@ -0,0 +1,43 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using EventExtensions; + using Parcel; + using Parcel.Events; + + public class ParcelWasRetiredV2Builder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private VbrCaPaKey? _vbrCaPaKey; + + public ParcelWasRetiredV2Builder(Fixture fixture) + { + _fixture = fixture; + } + + public ParcelWasRetiredV2Builder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ParcelWasRetiredV2Builder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public ParcelWasRetiredV2 Build() + { + var parcelWasRetiredV2 = new ParcelWasRetiredV2( + _parcelId ?? _fixture.Create(), + _vbrCaPaKey ?? _fixture.Create()); + parcelWasRetiredV2.SetFixtureProvenance(_fixture); + + return parcelWasRetiredV2; + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder.cs b/test/ParcelRegistry.Tests/Builders/ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder.cs new file mode 100644 index 00000000..73f03f80 --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder.cs @@ -0,0 +1,50 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using Parcel; + using Parcel.Commands; + + public class ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder + { + private readonly Fixture _fixture; + private ParcelId? _parcelId; + private AddressPersistentLocalId? _newAddressPersistentLocalId; + private AddressPersistentLocalId? _previousAddressPersistentLocalId; + + public ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder(Fixture fixture) + { + _fixture = fixture; + } + + public ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder WithParcelId(ParcelId parcelId) + { + _parcelId = parcelId; + + return this; + } + + public ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder WithNewAddress(int address) + { + _newAddressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ReplaceAttachedAddressBecauseAddressWasReaddressedBuilder WithPreviousAddress(int address) + { + _previousAddressPersistentLocalId = new AddressPersistentLocalId(address); + + return this; + } + + public ReplaceAttachedAddressBecauseAddressWasReaddressed Build() + { + return new ReplaceAttachedAddressBecauseAddressWasReaddressed( + _parcelId ?? _fixture.Create(), + _newAddressPersistentLocalId ?? _fixture.Create(), + _previousAddressPersistentLocalId ?? _fixture.Create(), + _fixture.Create()); + } + } +} diff --git a/test/ParcelRegistry.Tests/Builders/RetireParcelV2Builder.cs b/test/ParcelRegistry.Tests/Builders/RetireParcelV2Builder.cs new file mode 100644 index 00000000..f143affc --- /dev/null +++ b/test/ParcelRegistry.Tests/Builders/RetireParcelV2Builder.cs @@ -0,0 +1,34 @@ +namespace ParcelRegistry.Tests.Builders +{ + using AutoFixture; + using Be.Vlaanderen.Basisregisters.GrAr.Provenance; + using EventExtensions; + using Parcel; + using Parcel.Commands; + using Parcel.Events; + + public class RetireParcelV2Builder + { + private readonly Fixture _fixture; + private VbrCaPaKey? _vbrCaPaKey; + + public RetireParcelV2Builder(Fixture fixture) + { + _fixture = fixture; + } + + public RetireParcelV2Builder WithVbrCaPaKey(VbrCaPaKey vbrCaPaKey) + { + _vbrCaPaKey = vbrCaPaKey; + + return this; + } + + public RetireParcelV2 Build() + { + return new RetireParcelV2( + _vbrCaPaKey ?? _fixture.Create(), + _fixture.Create()); + } + } +}