Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: tests #715

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -26,25 +22,15 @@ public void ThenNothing()
{
var addressPersistentLocalId = new AddressPersistentLocalId(123);

var command = new AttachAddress(
Fixture.Create<ParcelId>(),
addressPersistentLocalId,
Fixture.Create<Provenance>());
var command = new AttachAddressBuilder(Fixture)
.WithAddress(addressPersistentLocalId)
.Build();

var parcelWasMigrated = new ParcelWasMigrated(
Fixture.Create<ParcelRegistry.Legacy.ParcelId>(),
command.ParcelId,
Fixture.Create<VbrCaPaKey>(),
ParcelStatus.Realized,
isRemoved: false,
new List<AddressPersistentLocalId>
{
addressPersistentLocalId,
new AddressPersistentLocalId(456),
new AddressPersistentLocalId(789),
},
GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry());
((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create<Provenance>());
var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture)
.WithParcelId(command.ParcelId)
.WithStatus(ParcelStatus.Realized)
.WithAddress(addressPersistentLocalId)
.Build();

Assert(new Scenario()
.Given(
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,25 +20,14 @@ public GivenAddressDoesNotExist(ITestOutputHelper testOutputHelper) : base(testO
[Fact]
public void ThenThrowAddressNotFoundException()
{
var command = new AttachAddress(
Fixture.Create<ParcelId>(),
new AddressPersistentLocalId(11111111),
Fixture.Create<Provenance>());
var command = new AttachAddressBuilder(Fixture)
.WithAddress(11111111)
.Build();

var parcelWasMigrated = new ParcelWasMigrated(
Fixture.Create<ParcelRegistry.Legacy.ParcelId>(),
command.ParcelId,
Fixture.Create<VbrCaPaKey>(),
ParcelStatus.Realized,
isRemoved: false,
new List<AddressPersistentLocalId>
{
new AddressPersistentLocalId(123),
new AddressPersistentLocalId(456),
new AddressPersistentLocalId(789),
},
GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry());
((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create<Provenance>());
var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture)
.WithParcelId(command.ParcelId)
.WithStatus(ParcelStatus.Realized)
.Build();

Assert(new Scenario()
.Given(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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<ParcelId>(),
addressPersistentLocalId,
Fixture.Create<Provenance>());
var command = new AttachAddressBuilder(Fixture)
.WithAddress(addressPersistentLocalId)
.Build();

var parcelWasMigrated = new ParcelWasMigrated(
Fixture.Create<ParcelRegistry.Legacy.ParcelId>(),
command.ParcelId,
Fixture.Create<VbrCaPaKey>(),
ParcelStatus.Realized,
isRemoved: false,
new List<AddressPersistentLocalId>
{
new AddressPersistentLocalId(123),
new AddressPersistentLocalId(456),
new AddressPersistentLocalId(789),
},
GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry());
((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create<Provenance>());
var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture)
.WithStatus(ParcelStatus.Realized)
.Build();

var consumerAddress = Container.Resolve<FakeConsumerAddressContext>();
consumerAddress.AddAddress(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -33,25 +28,13 @@ public void ThenThrowAddressIsRemovedException()
{
var addressPersistentLocalId = new AddressPersistentLocalId(11111111);

var command = new AttachAddress(
Fixture.Create<ParcelId>(),
addressPersistentLocalId,
Fixture.Create<Provenance>());
var command = new AttachAddressBuilder(Fixture)
.WithAddress(addressPersistentLocalId)
.Build();

var parcelWasMigrated = new ParcelWasMigrated(
Fixture.Create<ParcelRegistry.Legacy.ParcelId>(),
command.ParcelId,
Fixture.Create<VbrCaPaKey>(),
ParcelStatus.Realized,
isRemoved: false,
new List<AddressPersistentLocalId>
{
new AddressPersistentLocalId(123),
new AddressPersistentLocalId(456),
new AddressPersistentLocalId(789),
},
GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry());
((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create<Provenance>());
var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture)
.WithStatus(ParcelStatus.Realized)
.Build();

var consumerAddress = Container.Resolve<FakeConsumerAddressContext>();
consumerAddress.AddAddress(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace ParcelRegistry.Tests.AggregateTests.WhenAttachingParcelAddress
{
using System.Collections.Generic;
using Api.BackOffice.Abstractions.Extensions;
using Autofac;
using AutoFixture;
using BackOffice;
Expand All @@ -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
{
Expand All @@ -35,25 +33,13 @@ public void ThenParcelAddressWasAttachedV2()
{
var addressPersistentLocalId = new AddressPersistentLocalId(111);

var command = new AttachAddress(
Fixture.Create<ParcelId>(),
addressPersistentLocalId,
Fixture.Create<Provenance>());
var command = new AttachAddressBuilder(Fixture)
.WithAddress(addressPersistentLocalId)
.Build();

var parcelWasMigrated = new ParcelWasMigrated(
Fixture.Create<ParcelRegistry.Legacy.ParcelId>(),
command.ParcelId,
Fixture.Create<VbrCaPaKey>(),
ParcelStatus.Realized,
isRemoved: false,
new List<AddressPersistentLocalId>
{
new AddressPersistentLocalId(123),
new AddressPersistentLocalId(456),
new AddressPersistentLocalId(789),
},
GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry());
((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create<Provenance>());
var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture)
.WithStatus(ParcelStatus.Realized)
.Build();

var consumerAddress = Container.Resolve<FakeConsumerAddressContext>();
consumerAddress.AddAddress(
Expand All @@ -75,20 +61,10 @@ public void ThenParcelAddressWasAttachedV2()
[Fact]
public void StateCheck()
{
var parcelWasMigrated = new ParcelWasMigrated(
Fixture.Create<ParcelRegistry.Legacy.ParcelId>(),
Fixture.Create<ParcelId>(),
Fixture.Create<VbrCaPaKey>(),
ParcelStatus.Realized,
isRemoved: false,
new List<AddressPersistentLocalId>
{
new AddressPersistentLocalId(123),
new AddressPersistentLocalId(456),
new AddressPersistentLocalId(789),
},
GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry());
((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create<Provenance>());
var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture)
.WithStatus(ParcelStatus.Realized)
.WithAddress(123)
.Build();

var addressPersistentLocalId = new AddressPersistentLocalId(111);
var parcelAddressWasAttachedV2 = new ParcelAddressWasAttachedV2(Fixture.Create<ParcelId>(), new VbrCaPaKey(parcelWasMigrated.CaPaKey), addressPersistentLocalId);
Expand All @@ -99,7 +75,7 @@ public void StateCheck()
sut.Initialize(new List<object> { parcelWasMigrated, parcelAddressWasAttachedV2 });

// Assert
sut.AddressPersistentLocalIds.Should().HaveCount(4);
sut.AddressPersistentLocalIds.Should().HaveCount(2);
sut.AddressPersistentLocalIds.Should().Contain(addressPersistentLocalId);
sut.LastEventHash.Should().Be(parcelAddressWasAttachedV2.GetHash());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -31,27 +26,15 @@ public GivenParcelHasInvalidStatus(ITestOutputHelper testOutputHelper) : base(te
[Fact]
public void ThenThrowParcelHasInvalidStatusException()
{
var addressPersistentLocalId = new AddressPersistentLocalId(11111111);
var addressPersistentLocalId = Fixture.Create<AddressPersistentLocalId>();

var command = new AttachAddress(
Fixture.Create<ParcelId>(),
addressPersistentLocalId,
Fixture.Create<Provenance>());
var command = new AttachAddressBuilder(Fixture)
.WithAddress(addressPersistentLocalId)
.Build();

var parcelWasMigrated = new ParcelWasMigrated(
Fixture.Create<ParcelRegistry.Legacy.ParcelId>(),
command.ParcelId,
Fixture.Create<VbrCaPaKey>(),
ParcelStatus.Retired,
isRemoved: false,
new List<AddressPersistentLocalId>
{
new AddressPersistentLocalId(123),
new AddressPersistentLocalId(456),
new AddressPersistentLocalId(789),
},
GeometryHelpers.ValidGmlPolygon.GmlToExtendedWkbGeometry());
((ISetProvenance)parcelWasMigrated).SetProvenance(Fixture.Create<Provenance>());
var parcelWasMigrated = new ParcelWasMigratedBuilder(Fixture)
.WithStatus(ParcelStatus.Retired)
.Build();

var consumerAddress = Container.Resolve<FakeConsumerAddressContext>();
consumerAddress.AddAddress(
Expand Down
Loading
Loading