Skip to content

Commit

Permalink
test: add tests + add idempotencykey
Browse files Browse the repository at this point in the history
  • Loading branch information
emalfroy committed Jan 4, 2024
1 parent 8299400 commit 96520f7
Show file tree
Hide file tree
Showing 7 changed files with 1,894 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public sealed class AddressLatestItem
public string? PuriId { get; set; }
public string? Namespace { get; set; }
public string VersionAsString { get; set; }
public long IdempotenceKey { get; set; }

private DateTimeOffset VersionTimestampAsDateTimeOffset { get; set; }

Expand Down Expand Up @@ -84,6 +85,8 @@ public void Configure(EntityTypeBuilder<AddressLatestItem> builder)

builder.Ignore(x => x.VersionTimestamp);

builder.Property(x => x.IdempotenceKey).HasColumnName("idempotence_key");

builder.Property(x => x.PersistentLocalId).IsRequired();
builder.HasIndex(x => x.PersistentLocalId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class AddressLatestItemExtensions
{
public static async Task<AddressLatestItem> FindAndUpdateAddressLatestItem(this IntegrationContext context,
int persistentLocalId,
long position,
Action<AddressLatestItem> updateFunc,
CancellationToken ct)
{
Expand All @@ -19,6 +20,8 @@ public static async Task<AddressLatestItem> FindAndUpdateAddressLatestItem(this
if (addressLatestItem == null)
throw DatabaseItemNotFound(new PersistentLocalId(persistentLocalId));

addressLatestItem.IdempotenceKey = position;

updateFunc(addressLatestItem);

return addressLatestItem;
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/AddressRegistry.Tests/AddressRegistry.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ProjectReference Include="..\..\src\AddressRegistry.Consumer.Read.StreetName\AddressRegistry.Consumer.Read.StreetName.csproj" />
<ProjectReference Include="..\..\src\AddressRegistry.Consumer\AddressRegistry.Consumer.csproj" />
<ProjectReference Include="..\..\src\AddressRegistry.Projections.BackOffice\AddressRegistry.Projections.BackOffice.csproj" />
<ProjectReference Include="..\..\src\AddressRegistry.Projections.Integration\AddressRegistry.Projections.Integration.csproj" />
<ProjectReference Include="..\..\src\AddressRegistry.Projections.Wfs\AddressRegistry.Projections.Wfs.csproj" />
<ProjectReference Include="..\..\src\AddressRegistry.Projections.Wms\AddressRegistry.Projections.Wms.csproj" />
<ProjectReference Include="..\..\src\AddressRegistry\AddressRegistry.csproj" />
Expand Down
22 changes: 22 additions & 0 deletions test/AddressRegistry.Tests/AutoFixture/WithIntegerNisCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace AddressRegistry.Tests.AutoFixture
{
using global::AutoFixture;
using global::AutoFixture.Kernel;
using StreetName;

public class WithIntegerNisCode : ICustomization
{
public void Customize(IFixture fixture)
{
var nisCode = new NisCode(fixture.Create<int>().ToString());
fixture.Register(() => nisCode);

fixture.Customizations.Add(
new FilteringSpecimenBuilder(
new FixedBuilder(nisCode.ToString()),
new ParameterSpecification(
typeof(string),
"nisCode")));
}
}
}
1,773 changes: 1,773 additions & 0 deletions test/AddressRegistry.Tests/Integration/AddressLatestItemTest.cs

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions test/AddressRegistry.Tests/Integration/IntegrationsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace AddressRegistry.Tests.Integration
{
using System;
using Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector;
using Be.Vlaanderen.Basisregisters.ProjectionHandling.Testing;
using Microsoft.EntityFrameworkCore;
using Projections.Integration;

public abstract class IntegrationProjectionTest<TProjection>
where TProjection : ConnectedProjection<IntegrationContext>
{
protected ConnectedProjectionTest<IntegrationContext, TProjection> Sut { get; }

protected IntegrationProjectionTest()
{
Sut = new ConnectedProjectionTest<IntegrationContext, TProjection>(CreateContext, CreateProjection);
}

protected virtual IntegrationContext CreateContext()
{
var options = new DbContextOptionsBuilder<IntegrationContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;

return new IntegrationContext(options);
}

protected abstract TProjection CreateProjection();
}
}

0 comments on commit 96520f7

Please sign in to comment.