Skip to content
Closed
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
15 changes: 12 additions & 3 deletions tests/AggregateKit.Tests/EntityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,21 @@ public void Entity_Parameterless_Constructor_Works_For_EF_Core()
// This test ensures the parameterless constructor works (needed for EF Core)
// We can't directly test it since it's protected, but we can verify it exists
// by checking that the type can be instantiated through reflection

var entityType = typeof(TestEntity);
var constructors = entityType.GetConstructors(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var parameterlessConstructor = Array.Find(constructors, c => c.GetParameters().Length == 0);

Assert.NotNull(parameterlessConstructor);
}

[Fact]
public void Entity_ParameterlessConstructor_CanInstantiate()
{
var entity = new ParameterlessEntity();

Assert.NotNull(entity);
Assert.Equal(default(Guid), entity.Id);
}
}
}
}
12 changes: 12 additions & 0 deletions tests/AggregateKit.Tests/ParameterlessEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace AggregateKit.Tests
{
public class ParameterlessEntity : Entity<Guid>
{
public ParameterlessEntity() : base()
{
}
}
}