test(backend): Fix all compilation errors in Domain.Tests after Day 15 multi-tenant changes

Fixed 73 compilation errors caused by Epic/Story/WorkTask.Create() now requiring TenantId parameter.

Changes:
- Created TestDataBuilder helper class for test data creation
- Updated EpicTests.cs: Added TenantId to all Epic.Create() calls (10 tests)
- Updated StoryTests.cs: Added TenantId to all Story.Create() calls (26 tests)
- Updated WorkTaskTests.cs: Added TenantId to all WorkTask.Create() calls (37 tests)
- Added using ColaFlow.Domain.Tests.Builders to all test files

Test Results:
- Build: 0 errors, 9 warnings (xUnit analyzer warnings only)
- Tests: 192/192 passed in ColaFlow.Domain.Tests
- Full Suite: 427/431 passed (4 skipped as expected)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yaojia Wang
2025-11-04 17:25:00 +01:00
parent d2ed21873e
commit 0854faccc1
4 changed files with 193 additions and 73 deletions

View File

@@ -1,6 +1,7 @@
using ColaFlow.Modules.ProjectManagement.Domain.Aggregates.ProjectAggregate;
using ColaFlow.Modules.ProjectManagement.Domain.ValueObjects;
using ColaFlow.Modules.ProjectManagement.Domain.Exceptions;
using ColaFlow.Domain.Tests.Builders;
using FluentAssertions;
namespace ColaFlow.Domain.Tests.Aggregates;
@@ -23,7 +24,7 @@ public class StoryTests
var createdBy = UserId.Create();
// Act
var story = Story.Create(title, description, epicId, priority, createdBy);
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), title, description, epicId, priority, createdBy);
// Assert
story.Should().NotBeNull();
@@ -52,7 +53,7 @@ public class StoryTests
var createdBy = UserId.Create();
// Act
var story = Story.Create(title, description!, epicId, priority, createdBy);
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), title, description!, epicId, priority, createdBy);
// Assert
story.Should().NotBeNull();
@@ -71,7 +72,7 @@ public class StoryTests
var createdBy = UserId.Create();
// Act
Action act = () => Story.Create(invalidTitle, "Description", epicId, priority, createdBy);
Action act = () => Story.Create(TestDataBuilder.CreateTestTenantId(), invalidTitle, "Description", epicId, priority, createdBy);
// Assert
act.Should().Throw<DomainException>()
@@ -88,7 +89,7 @@ public class StoryTests
var createdBy = UserId.Create();
// Act
Action act = () => Story.Create(title, "Description", epicId, priority, createdBy);
Action act = () => Story.Create(TestDataBuilder.CreateTestTenantId(), title, "Description", epicId, priority, createdBy);
// Assert
act.Should().Throw<DomainException>()
@@ -105,7 +106,7 @@ public class StoryTests
var createdBy = UserId.Create();
// Act
var story = Story.Create(title, "Description", epicId, priority, createdBy);
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), title, "Description", epicId, priority, createdBy);
// Assert
story.Should().NotBeNull();
@@ -120,7 +121,7 @@ public class StoryTests
public void CreateTask_WithValidData_ShouldCreateTask()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var taskTitle = "Task 1";
var taskDescription = "Task Description";
var priority = TaskPriority.Urgent;
@@ -144,7 +145,7 @@ public class StoryTests
public void CreateTask_MultipleTasks_ShouldAddToCollection()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var createdBy = UserId.Create();
// Act
@@ -165,7 +166,7 @@ public class StoryTests
public void UpdateDetails_WithValidData_ShouldUpdateStory()
{
// Arrange
var story = Story.Create("Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var originalCreatedAt = story.CreatedAt;
var newTitle = "Updated Title";
var newDescription = "Updated Description";
@@ -185,7 +186,7 @@ public class StoryTests
public void UpdateDetails_WithNullDescription_ShouldSetEmptyDescription()
{
// Arrange
var story = Story.Create("Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
story.UpdateDetails("Updated Title", null!);
@@ -201,7 +202,7 @@ public class StoryTests
public void UpdateDetails_WithEmptyTitle_ShouldThrowDomainException(string invalidTitle)
{
// Arrange
var story = Story.Create("Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
Action act = () => story.UpdateDetails(invalidTitle, "Updated Description");
@@ -215,7 +216,7 @@ public class StoryTests
public void UpdateDetails_WithTitleExceeding200Characters_ShouldThrowDomainException()
{
// Arrange
var story = Story.Create("Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Original Title", "Original Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var title = new string('A', 201);
// Act
@@ -234,7 +235,7 @@ public class StoryTests
public void UpdateStatus_WithValidStatus_ShouldUpdateStatus()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var newStatus = WorkItemStatus.InProgress;
// Act
@@ -250,7 +251,7 @@ public class StoryTests
public void UpdateStatus_ToAllStatuses_ShouldSucceed()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act & Assert
story.UpdateStatus(WorkItemStatus.InProgress);
@@ -277,7 +278,7 @@ public class StoryTests
public void AssignTo_WithValidUserId_ShouldAssignStory()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var assigneeId = UserId.Create();
// Act
@@ -293,7 +294,7 @@ public class StoryTests
public void AssignTo_ReassignToDifferentUser_ShouldUpdateAssignee()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var firstAssignee = UserId.Create();
var secondAssignee = UserId.Create();
@@ -313,7 +314,7 @@ public class StoryTests
public void UpdateEstimate_WithValidHours_ShouldUpdateEstimate()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var hours = 8.5m;
// Act
@@ -329,7 +330,7 @@ public class StoryTests
public void UpdateEstimate_WithZeroHours_ShouldSucceed()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
story.UpdateEstimate(0);
@@ -342,7 +343,7 @@ public class StoryTests
public void UpdateEstimate_WithNegativeHours_ShouldThrowDomainException()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
Action act = () => story.UpdateEstimate(-1);
@@ -356,7 +357,7 @@ public class StoryTests
public void UpdateEstimate_MultipleUpdates_ShouldOverwritePreviousValue()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
story.UpdateEstimate(8);
@@ -374,7 +375,7 @@ public class StoryTests
public void LogActualHours_WithValidHours_ShouldLogHours()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var hours = 10.5m;
// Act
@@ -390,7 +391,7 @@ public class StoryTests
public void LogActualHours_WithZeroHours_ShouldSucceed()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
story.LogActualHours(0);
@@ -403,7 +404,7 @@ public class StoryTests
public void LogActualHours_WithNegativeHours_ShouldThrowDomainException()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
Action act = () => story.LogActualHours(-1);
@@ -417,7 +418,7 @@ public class StoryTests
public void LogActualHours_MultipleUpdates_ShouldOverwritePreviousValue()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act
story.LogActualHours(8);
@@ -435,7 +436,7 @@ public class StoryTests
public void Tasks_Collection_ShouldBeReadOnly()
{
// Arrange
var story = Story.Create("Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
var story = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", EpicId.Create(), TaskPriority.Medium, UserId.Create());
// Act & Assert
story.Tasks.Should().BeAssignableTo<IReadOnlyCollection<WorkTask>>();
@@ -447,8 +448,8 @@ public class StoryTests
// Arrange & Act
var epicId = EpicId.Create();
var createdBy = UserId.Create();
var story1 = Story.Create("Story 1", "Description", epicId, TaskPriority.Medium, createdBy);
var story2 = Story.Create("Story 2", "Description", epicId, TaskPriority.Medium, createdBy);
var story1 = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 1", "Description", epicId, TaskPriority.Medium, createdBy);
var story2 = Story.Create(TestDataBuilder.CreateTestTenantId(), "Story 2", "Description", epicId, TaskPriority.Medium, createdBy);
// Assert
story1.Id.Should().NotBe(story2.Id);