Skip to content

Add parameterless entity test#11

Closed
suranig wants to merge 1 commit into
masterfrom
fck502-codex/add-test-for-parameterless-constructor
Closed

Add parameterless entity test#11
suranig wants to merge 1 commit into
masterfrom
fck502-codex/add-test-for-parameterless-constructor

Conversation

@suranig

@suranig suranig commented Jun 9, 2025

Copy link
Copy Markdown
Owner

Summary

  • add ParameterlessEntity class derived from Entity<Guid> with a public parameterless constructor
  • test that an instance can be constructed with the parameterless constructor

Testing

  • dotnet test (fails: dotnet command not found)

https://chatgpt.com/codex/tasks/task_e_6846faf84f1c8327857ba21b76f3d849

@codecov

codecov Bot commented Jun 9, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Default ID in Public Constructor

The public parameterless constructor of ParameterlessEntity allows creating entities with default(Guid) IDs, which contradicts the Entity class design requiring valid, non-default IDs. Other constructors enforce this rule by throwing ArgumentException, but this public constructor bypasses it, as confirmed by the new test Entity_ParameterlessConstructor_CanInstantiate asserting a default ID. This constructor should be protected/internal for ORM use or generate a valid ID.

tests/AggregateKit.Tests/ParameterlessEntity.cs#L4-L10

{
public class ParameterlessEntity : Entity<Guid>
{
public ParameterlessEntity() : base()
{
}
}

tests/AggregateKit.Tests/EntityTests.cs#L255-L263

[Fact]
public void Entity_ParameterlessConstructor_CanInstantiate()
{
var entity = new ParameterlessEntity();
Assert.NotNull(entity);
Assert.Equal(default(Guid), entity.Id);
}

Fix in Cursor


Bug: Entity Validation Inconsistency

The new test Entity_ParameterlessConstructor_CanInstantiate asserts an entity's ID is default(Guid). This conflicts with existing validation that requires non-default GUIDs, causing parameterized constructors to reject default(Guid) IDs while the parameterless constructor allows them. This inconsistency permits entities to exist in an invalid state.

tests/AggregateKit.Tests/EntityTests.cs#L255-L263

[Fact]
public void Entity_ParameterlessConstructor_CanInstantiate()
{
var entity = new ParameterlessEntity();
Assert.NotNull(entity);
Assert.Equal(default(Guid), entity.Id);
}

Fix in Cursor


BugBot free trial expires on June 9, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@suranig suranig closed this Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant