From 0cf2ee5246fd15c6eb315cdac863c33758cf663b Mon Sep 17 00:00:00 2001 From: tumiwisista Date: Mon, 9 Jun 2025 17:23:27 +0200 Subject: [PATCH] Add parameterless entity test --- tests/AggregateKit.Tests/EntityTests.cs | 15 ++++++++++++--- tests/AggregateKit.Tests/ParameterlessEntity.cs | 12 ++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/AggregateKit.Tests/ParameterlessEntity.cs diff --git a/tests/AggregateKit.Tests/EntityTests.cs b/tests/AggregateKit.Tests/EntityTests.cs index 7e2fc7f..5eeb115 100644 --- a/tests/AggregateKit.Tests/EntityTests.cs +++ b/tests/AggregateKit.Tests/EntityTests.cs @@ -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); + } } -} \ No newline at end of file +} diff --git a/tests/AggregateKit.Tests/ParameterlessEntity.cs b/tests/AggregateKit.Tests/ParameterlessEntity.cs new file mode 100644 index 0000000..cefe017 --- /dev/null +++ b/tests/AggregateKit.Tests/ParameterlessEntity.cs @@ -0,0 +1,12 @@ +using System; + +namespace AggregateKit.Tests +{ + public class ParameterlessEntity : Entity + { + public ParameterlessEntity() : base() + { + } + } +} +