Skip to content

Commit 6c87a61

Browse files
committed
Add missing test for the ComplexPropertyBuilderConfiguration.cs
which triggered a few other code changes but, test-wise, it compiles and passes
1 parent 631f417 commit 6c87a61

File tree

9 files changed

+84
-40
lines changed

9 files changed

+84
-40
lines changed

src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DeletionStatusConfiguration.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
77

88
internal sealed class DeletionStatusConfiguration : IComplexPropertyConfiguration<DeletionStatus>
99
{
10-
public ComplexPropertyBuilder<DeletionStatus> Configure(ComplexPropertyBuilder<DeletionStatus> builder)
10+
public void Configure(ComplexPropertyBuilder<DeletionStatus> builder)
1111
{
1212
builder
1313
.Property(deletionStatus => deletionStatus.HardDeletePending)
1414
.HasColumnName("HardDeletePending")
1515
.HasColumnType("datetimeoffset");
16-
16+
1717
builder
1818
.Property(deletionStatus => deletionStatus.SoftDeletePending)
1919
.HasColumnName("SoftDeletePending")
@@ -23,7 +23,5 @@ public ComplexPropertyBuilder<DeletionStatus> Configure(ComplexPropertyBuilder<D
2323
.Property(deletionStatus => deletionStatus.SoftDeleted)
2424
.HasColumnName("SoftDeleted")
2525
.HasColumnType("datetimeoffset");
26-
27-
return builder;
2826
}
2927
}

src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DirectoryNameConfiguration.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
77

88
internal sealed class DirectoryNameConfiguration : IComplexPropertyConfiguration<DirectoryName>
99
{
10-
public ComplexPropertyBuilder<DirectoryName> Configure(ComplexPropertyBuilder<DirectoryName> builder)
10+
public void Configure(ComplexPropertyBuilder<DirectoryName> builder)
1111
{
1212
builder.Property(directoryName => directoryName.Value)
1313
.HasColumnName("DirectoryName")
1414
.HasColumnType("nvarchar(256)");
15-
16-
return builder;
1715
}
1816
}

src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventTypeConfiguration.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
77

88
internal sealed class EventTypeConfiguration : IComplexPropertyConfiguration<EventType>
99
{
10-
public ComplexPropertyBuilder<EventType> Configure(ComplexPropertyBuilder<EventType> builder)
10+
public void Configure(ComplexPropertyBuilder<EventType> builder)
1111
{
1212
builder.Property(eventType => eventType.Value).HasColumnName("EventType").IsRequired();
1313
builder.Property(eventType => eventType.Name).HasColumnName("EventName").IsRequired();
14-
15-
return builder;
1614
}
1715
}

src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/ImageDetailConfiguration.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
77

88
internal sealed class ImageDetailConfiguration : IComplexPropertyConfiguration<ImageDetail>
99
{
10-
public ComplexPropertyBuilder<ImageDetail> Configure(ComplexPropertyBuilder<ImageDetail> builder)
10+
public void Configure(ComplexPropertyBuilder<ImageDetail> builder)
1111
{
1212
builder.Property(image => image.Width).HasColumnName("ImageWidth");
1313
builder.Property(image => image.Height).HasColumnName("ImageHeight");
14-
15-
return builder;
1614
}
1715
}

src/AStar.Dev.Infrastructure/AStar.Dev.Infrastructure.xml

Lines changed: 35 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AStar.Dev.Infrastructure/Data/Configurations/ComplexPropertyBuilderConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class ComplexPropertyBuilderConfiguration
1212
/// <param name="configuration"></param>
1313
/// <typeparam name="TEntity"></typeparam>
1414
/// <returns></returns>
15-
public static ComplexPropertyBuilder<TEntity> Configure<TEntity>(this ComplexPropertyBuilder<TEntity> propertyBuilder, IComplexPropertyConfiguration<TEntity> configuration)
15+
public static ComplexPropertyBuilder<TEntity> Configure<TEntity>(this ComplexPropertyBuilder<TEntity> propertyBuilder, IComplexPropertyConfiguration<TEntity> configuration)
1616
{
1717
configuration.Configure(propertyBuilder);
1818

src/AStar.Dev.Infrastructure/Data/Configurations/IComplexPropertyConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ namespace AStar.Dev.Infrastructure.Data.Configurations;
55
/// <summary>
66
/// </summary>
77
/// <typeparam name="TEntity"></typeparam>
8-
public interface IComplexPropertyConfiguration<TEntity>
8+
public interface IComplexPropertyConfiguration<TEntity>
99
{
1010
/// <summary>
1111
/// </summary>
1212
/// <param name="builder"></param>
1313
/// <returns></returns>
14-
public ComplexPropertyBuilder<TEntity> Configure(ComplexPropertyBuilder<TEntity> builder);
14+
public void Configure(ComplexPropertyBuilder<TEntity> builder);
1515
}

test/AStar.Dev.Infrastructure.Tests.Unit/AuditableEntityShould.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void ContainTheExpectedProperties()
1212
.ToJson()
1313
.ShouldMatchApproved();
1414

15-
private class MockAuditableEntity : AuditableEntity
15+
private sealed class MockAuditableEntity : AuditableEntity
1616
{
1717
}
1818
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using AStar.Dev.Infrastructure.Data.Configurations;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
4+
5+
namespace AStar.Dev.Infrastructure.Tests.Unit;
6+
7+
public class ComplexPropertyBuilderConfigurationShould
8+
{
9+
private sealed class DummyEntity
10+
{
11+
public Address Address { get; set; } = new();
12+
}
13+
14+
private sealed class Address
15+
{
16+
public string Street { get; set; } = string.Empty;
17+
}
18+
19+
private sealed class TestConfiguration : IComplexPropertyConfiguration<Address>
20+
{
21+
public bool WasCalled { get; private set; }
22+
23+
public void Configure(ComplexPropertyBuilder<Address> builder) => WasCalled = true;
24+
}
25+
26+
[Fact]
27+
public void Configure_ShouldInvokeConfigurationAndReturnSameBuilder()
28+
{
29+
var modelBuilder = new ModelBuilder();
30+
var entityBuilder = modelBuilder.Entity<DummyEntity>();
31+
var complexBuilder = entityBuilder.ComplexProperty(e => e.Address);
32+
33+
var config = new TestConfiguration();
34+
35+
var result = complexBuilder.Configure(config);
36+
37+
Assert.True(config.WasCalled);
38+
Assert.Same(complexBuilder, result);
39+
}
40+
}

0 commit comments

Comments
 (0)