Project Init

🤖 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-02 23:55:18 +01:00
commit 014d62bcc2
169 changed files with 28867 additions and 0 deletions

View File

@@ -0,0 +1,238 @@
using ColaFlow.Modules.ProjectManagement.Domain.ValueObjects;
using FluentAssertions;
namespace ColaFlow.Domain.Tests.ValueObjects;
/// <summary>
/// Unit tests for Enumeration-based value objects
/// </summary>
public class EnumerationTests
{
#region ProjectStatus Tests
[Fact]
public void ProjectStatus_Active_ShouldHaveCorrectValues()
{
// Assert
ProjectStatus.Active.Id.Should().Be(1);
ProjectStatus.Active.Name.Should().Be("Active");
}
[Fact]
public void ProjectStatus_Archived_ShouldHaveCorrectValues()
{
// Assert
ProjectStatus.Archived.Id.Should().Be(2);
ProjectStatus.Archived.Name.Should().Be("Archived");
}
[Fact]
public void ProjectStatus_OnHold_ShouldHaveCorrectValues()
{
// Assert
ProjectStatus.OnHold.Id.Should().Be(3);
ProjectStatus.OnHold.Name.Should().Be("On Hold");
}
[Fact]
public void ProjectStatus_Equals_WithSameStatus_ShouldReturnTrue()
{
// Arrange
var status1 = ProjectStatus.Active;
var status2 = ProjectStatus.Active;
// Act & Assert
status1.Should().Be(status2);
status1.Equals(status2).Should().BeTrue();
}
[Fact]
public void ProjectStatus_Equals_WithDifferentStatus_ShouldReturnFalse()
{
// Arrange
var status1 = ProjectStatus.Active;
var status2 = ProjectStatus.Archived;
// Act & Assert
status1.Should().NotBe(status2);
status1.Equals(status2).Should().BeFalse();
}
[Fact]
public void ProjectStatus_ToString_ShouldReturnName()
{
// Arrange
var status = ProjectStatus.Active;
// Act
var result = status.ToString();
// Assert
result.Should().Be("Active");
}
#endregion
#region WorkItemStatus Tests
[Fact]
public void WorkItemStatus_ToDo_ShouldHaveCorrectValues()
{
// Assert
WorkItemStatus.ToDo.Id.Should().Be(1);
WorkItemStatus.ToDo.Name.Should().Be("To Do");
}
[Fact]
public void WorkItemStatus_InProgress_ShouldHaveCorrectValues()
{
// Assert
WorkItemStatus.InProgress.Id.Should().Be(2);
WorkItemStatus.InProgress.Name.Should().Be("In Progress");
}
[Fact]
public void WorkItemStatus_InReview_ShouldHaveCorrectValues()
{
// Assert
WorkItemStatus.InReview.Id.Should().Be(3);
WorkItemStatus.InReview.Name.Should().Be("In Review");
}
[Fact]
public void WorkItemStatus_Done_ShouldHaveCorrectValues()
{
// Assert
WorkItemStatus.Done.Id.Should().Be(4);
WorkItemStatus.Done.Name.Should().Be("Done");
}
[Fact]
public void WorkItemStatus_Blocked_ShouldHaveCorrectValues()
{
// Assert
WorkItemStatus.Blocked.Id.Should().Be(5);
WorkItemStatus.Blocked.Name.Should().Be("Blocked");
}
[Fact]
public void WorkItemStatus_Equals_WithSameStatus_ShouldReturnTrue()
{
// Arrange
var status1 = WorkItemStatus.ToDo;
var status2 = WorkItemStatus.ToDo;
// Act & Assert
status1.Should().Be(status2);
status1.Equals(status2).Should().BeTrue();
}
[Fact]
public void WorkItemStatus_Equals_WithDifferentStatus_ShouldReturnFalse()
{
// Arrange
var status1 = WorkItemStatus.ToDo;
var status2 = WorkItemStatus.Done;
// Act & Assert
status1.Should().NotBe(status2);
status1.Equals(status2).Should().BeFalse();
}
[Fact]
public void WorkItemStatus_ToString_ShouldReturnName()
{
// Arrange
var status = WorkItemStatus.InProgress;
// Act
var result = status.ToString();
// Assert
result.Should().Be("In Progress");
}
#endregion
#region TaskPriority Tests
[Fact]
public void TaskPriority_Low_ShouldHaveCorrectValues()
{
// Assert
TaskPriority.Low.Id.Should().Be(1);
TaskPriority.Low.Name.Should().Be("Low");
}
[Fact]
public void TaskPriority_Medium_ShouldHaveCorrectValues()
{
// Assert
TaskPriority.Medium.Id.Should().Be(2);
TaskPriority.Medium.Name.Should().Be("Medium");
}
[Fact]
public void TaskPriority_High_ShouldHaveCorrectValues()
{
// Assert
TaskPriority.High.Id.Should().Be(3);
TaskPriority.High.Name.Should().Be("High");
}
[Fact]
public void TaskPriority_Urgent_ShouldHaveCorrectValues()
{
// Assert
TaskPriority.Urgent.Id.Should().Be(4);
TaskPriority.Urgent.Name.Should().Be("Urgent");
}
[Fact]
public void TaskPriority_Equals_WithSamePriority_ShouldReturnTrue()
{
// Arrange
var priority1 = TaskPriority.High;
var priority2 = TaskPriority.High;
// Act & Assert
priority1.Should().Be(priority2);
priority1.Equals(priority2).Should().BeTrue();
}
[Fact]
public void TaskPriority_Equals_WithDifferentPriority_ShouldReturnFalse()
{
// Arrange
var priority1 = TaskPriority.Low;
var priority2 = TaskPriority.Urgent;
// Act & Assert
priority1.Should().NotBe(priority2);
priority1.Equals(priority2).Should().BeFalse();
}
[Fact]
public void TaskPriority_ToString_ShouldReturnName()
{
// Arrange
var priority = TaskPriority.Medium;
// Act
var result = priority.ToString();
// Assert
result.Should().Be("Medium");
}
[Fact]
public void TaskPriority_ShouldBeOrderedByImportance()
{
// Arrange & Act & Assert
TaskPriority.Low.Id.Should().BeLessThan(TaskPriority.Medium.Id);
TaskPriority.Medium.Id.Should().BeLessThan(TaskPriority.High.Id);
TaskPriority.High.Id.Should().BeLessThan(TaskPriority.Urgent.Id);
}
#endregion
}

View File

@@ -0,0 +1,126 @@
using ColaFlow.Modules.ProjectManagement.Domain.ValueObjects;
using FluentAssertions;
namespace ColaFlow.Domain.Tests.ValueObjects;
/// <summary>
/// Unit tests for ProjectId value object
/// </summary>
public class ProjectIdTests
{
[Fact]
public void Create_WithoutParameter_ShouldGenerateNewGuid()
{
// Act
var projectId = ProjectId.Create();
// Assert
projectId.Should().NotBeNull();
projectId.Value.Should().NotBe(Guid.Empty);
}
[Fact]
public void Create_WithGuid_ShouldCreateProjectIdWithGivenValue()
{
// Arrange
var guid = Guid.NewGuid();
// Act
var projectId = ProjectId.Create(guid);
// Assert
projectId.Value.Should().Be(guid);
}
[Fact]
public void From_WithGuid_ShouldCreateProjectId()
{
// Arrange
var guid = Guid.NewGuid();
// Act
var projectId = ProjectId.From(guid);
// Assert
projectId.Value.Should().Be(guid);
}
[Fact]
public void Create_MultipleCalls_ShouldGenerateDifferentGuids()
{
// Act
var projectId1 = ProjectId.Create();
var projectId2 = ProjectId.Create();
// Assert
projectId1.Value.Should().NotBe(projectId2.Value);
}
[Fact]
public void Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
var guid = Guid.NewGuid();
var projectId1 = ProjectId.Create(guid);
var projectId2 = ProjectId.Create(guid);
// Act & Assert
projectId1.Should().Be(projectId2);
projectId1.Equals(projectId2).Should().BeTrue();
}
[Fact]
public void Equals_WithDifferentValue_ShouldReturnFalse()
{
// Arrange
var projectId1 = ProjectId.Create();
var projectId2 = ProjectId.Create();
// Act & Assert
projectId1.Should().NotBe(projectId2);
projectId1.Equals(projectId2).Should().BeFalse();
}
[Fact]
public void GetHashCode_WithSameValue_ShouldReturnSameHashCode()
{
// Arrange
var guid = Guid.NewGuid();
var projectId1 = ProjectId.Create(guid);
var projectId2 = ProjectId.Create(guid);
// Act & Assert
projectId1.GetHashCode().Should().Be(projectId2.GetHashCode());
}
[Fact]
public void ToString_ShouldReturnGuidString()
{
// Arrange
var guid = Guid.NewGuid();
var projectId = ProjectId.Create(guid);
// Act
var result = projectId.ToString();
// Assert
result.Should().Be(guid.ToString());
}
[Fact]
public void ValueObject_ShouldBeImmutable()
{
// Arrange
var guid = Guid.NewGuid();
var projectId = ProjectId.Create(guid);
var originalValue = projectId.Value;
// Act - Try to get the value multiple times
var value1 = projectId.Value;
var value2 = projectId.Value;
// Assert
value1.Should().Be(originalValue);
value2.Should().Be(originalValue);
}
}

View File

@@ -0,0 +1,182 @@
using ColaFlow.Modules.ProjectManagement.Domain.ValueObjects;
using ColaFlow.Modules.ProjectManagement.Domain.Exceptions;
using FluentAssertions;
namespace ColaFlow.Domain.Tests.ValueObjects;
/// <summary>
/// Unit tests for ProjectKey value object
/// </summary>
public class ProjectKeyTests
{
[Fact]
public void Create_WithValidKey_ShouldCreateProjectKey()
{
// Arrange
var key = "COLA";
// Act
var projectKey = ProjectKey.Create(key);
// Assert
projectKey.Should().NotBeNull();
projectKey.Value.Should().Be(key);
}
[Theory]
[InlineData("A")]
[InlineData("AB")]
[InlineData("ABC")]
[InlineData("ABCD")]
[InlineData("ABCDEFGHIJ")] // 10 characters - max allowed
public void Create_WithValidLengthKeys_ShouldSucceed(string key)
{
// Act
var projectKey = ProjectKey.Create(key);
// Assert
projectKey.Value.Should().Be(key);
}
[Theory]
[InlineData("TEST")]
[InlineData("COLA")]
[InlineData("FLOW")]
[InlineData("PROJECT1")]
[InlineData("ABC123")]
public void Create_WithUppercaseLettersAndNumbers_ShouldSucceed(string key)
{
// Act
var projectKey = ProjectKey.Create(key);
// Assert
projectKey.Value.Should().Be(key);
}
[Theory]
[InlineData("")]
[InlineData(" ")]
[InlineData(null)]
public void Create_WithEmptyKey_ShouldThrowDomainException(string invalidKey)
{
// Act
Action act = () => ProjectKey.Create(invalidKey);
// Assert
act.Should().Throw<DomainException>()
.WithMessage("Project key cannot be empty");
}
[Fact]
public void Create_WithKeyExceeding10Characters_ShouldThrowDomainException()
{
// Arrange
var key = "ABCDEFGHIJK"; // 11 characters
// Act
Action act = () => ProjectKey.Create(key);
// Assert
act.Should().Throw<DomainException>()
.WithMessage("Project key cannot exceed 10 characters");
}
[Theory]
[InlineData("test")] // lowercase
[InlineData("Test")] // mixed case
[InlineData("TEST-1")] // hyphen
[InlineData("TEST_1")] // underscore
[InlineData("TEST 1")] // space
[InlineData("TEST.1")] // dot
[InlineData("TEST@1")] // special char
public void Create_WithInvalidCharacters_ShouldThrowDomainException(string invalidKey)
{
// Act
Action act = () => ProjectKey.Create(invalidKey);
// Assert
act.Should().Throw<DomainException>()
.WithMessage("Project key must contain only uppercase letters and numbers");
}
[Fact]
public void Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
var key = "TEST";
var projectKey1 = ProjectKey.Create(key);
var projectKey2 = ProjectKey.Create(key);
// Act & Assert
projectKey1.Should().Be(projectKey2);
projectKey1.Equals(projectKey2).Should().BeTrue();
}
[Fact]
public void Equals_WithDifferentValue_ShouldReturnFalse()
{
// Arrange
var projectKey1 = ProjectKey.Create("TEST1");
var projectKey2 = ProjectKey.Create("TEST2");
// Act & Assert
projectKey1.Should().NotBe(projectKey2);
projectKey1.Equals(projectKey2).Should().BeFalse();
}
[Fact]
public void GetHashCode_WithSameValue_ShouldReturnSameHashCode()
{
// Arrange
var key = "TEST";
var projectKey1 = ProjectKey.Create(key);
var projectKey2 = ProjectKey.Create(key);
// Act & Assert
projectKey1.GetHashCode().Should().Be(projectKey2.GetHashCode());
}
[Fact]
public void ToString_ShouldReturnKeyValue()
{
// Arrange
var key = "COLA";
var projectKey = ProjectKey.Create(key);
// Act
var result = projectKey.ToString();
// Assert
result.Should().Be(key);
}
[Fact]
public void ValueObject_ShouldBeImmutable()
{
// Arrange
var key = "TEST";
var projectKey = ProjectKey.Create(key);
var originalValue = projectKey.Value;
// Act - Try to get the value multiple times
var value1 = projectKey.Value;
var value2 = projectKey.Value;
// Assert
value1.Should().Be(originalValue);
value2.Should().Be(originalValue);
}
[Theory]
[InlineData("123")]
[InlineData("789")]
[InlineData("1234567890")]
public void Create_WithOnlyNumbers_ShouldSucceed(string key)
{
// Act
var projectKey = ProjectKey.Create(key);
// Assert
projectKey.Value.Should().Be(key);
}
}

View File

@@ -0,0 +1,203 @@
using ColaFlow.Modules.ProjectManagement.Domain.ValueObjects;
using FluentAssertions;
namespace ColaFlow.Domain.Tests.ValueObjects;
/// <summary>
/// Unit tests for strongly-typed ID value objects (EpicId, StoryId, TaskId, UserId)
/// </summary>
public class StronglyTypedIdTests
{
#region EpicId Tests
[Fact]
public void EpicId_Create_WithoutParameter_ShouldGenerateNewGuid()
{
// Act
var epicId = EpicId.Create();
// Assert
epicId.Should().NotBeNull();
epicId.Value.Should().NotBe(Guid.Empty);
}
[Fact]
public void EpicId_Create_WithGuid_ShouldCreateEpicIdWithGivenValue()
{
// Arrange
var guid = Guid.NewGuid();
// Act
var epicId = EpicId.Create(guid);
// Assert
epicId.Value.Should().Be(guid);
}
[Fact]
public void EpicId_Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
var guid = Guid.NewGuid();
var epicId1 = EpicId.Create(guid);
var epicId2 = EpicId.Create(guid);
// Act & Assert
epicId1.Should().Be(epicId2);
}
#endregion
#region StoryId Tests
[Fact]
public void StoryId_Create_WithoutParameter_ShouldGenerateNewGuid()
{
// Act
var storyId = StoryId.Create();
// Assert
storyId.Should().NotBeNull();
storyId.Value.Should().NotBe(Guid.Empty);
}
[Fact]
public void StoryId_Create_WithGuid_ShouldCreateStoryIdWithGivenValue()
{
// Arrange
var guid = Guid.NewGuid();
// Act
var storyId = StoryId.Create(guid);
// Assert
storyId.Value.Should().Be(guid);
}
[Fact]
public void StoryId_Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
var guid = Guid.NewGuid();
var storyId1 = StoryId.Create(guid);
var storyId2 = StoryId.Create(guid);
// Act & Assert
storyId1.Should().Be(storyId2);
}
#endregion
#region TaskId Tests
[Fact]
public void TaskId_Create_WithoutParameter_ShouldGenerateNewGuid()
{
// Act
var taskId = TaskId.Create();
// Assert
taskId.Should().NotBeNull();
taskId.Value.Should().NotBe(Guid.Empty);
}
[Fact]
public void TaskId_Create_WithGuid_ShouldCreateTaskIdWithGivenValue()
{
// Arrange
var guid = Guid.NewGuid();
// Act
var taskId = TaskId.Create(guid);
// Assert
taskId.Value.Should().Be(guid);
}
[Fact]
public void TaskId_Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
var guid = Guid.NewGuid();
var taskId1 = TaskId.Create(guid);
var taskId2 = TaskId.Create(guid);
// Act & Assert
taskId1.Should().Be(taskId2);
}
#endregion
#region UserId Tests
[Fact]
public void UserId_Create_WithoutParameter_ShouldGenerateNewGuid()
{
// Act
var userId = UserId.Create();
// Assert
userId.Should().NotBeNull();
userId.Value.Should().NotBe(Guid.Empty);
}
[Fact]
public void UserId_Create_WithGuid_ShouldCreateUserIdWithGivenValue()
{
// Arrange
var guid = Guid.NewGuid();
// Act
var userId = UserId.Create(guid);
// Assert
userId.Value.Should().Be(guid);
}
[Fact]
public void UserId_Equals_WithSameValue_ShouldReturnTrue()
{
// Arrange
var guid = Guid.NewGuid();
var userId1 = UserId.Create(guid);
var userId2 = UserId.Create(guid);
// Act & Assert
userId1.Should().Be(userId2);
}
#endregion
#region Type Safety Tests
[Fact]
public void DifferentIdTypes_WithSameGuid_ShouldNotBeEqual()
{
// Arrange
var guid = Guid.NewGuid();
var projectId = ProjectId.Create(guid);
var epicId = EpicId.Create(guid);
// Act & Assert - They are different types, so should not be equal
projectId.Should().NotBe((object)epicId);
}
[Fact]
public void MultipleCalls_ShouldGenerateDifferentGuids()
{
// Act
var id1 = ProjectId.Create();
var id2 = ProjectId.Create();
var id3 = EpicId.Create();
var id4 = StoryId.Create();
var id5 = TaskId.Create();
// Assert
id1.Value.Should().NotBe(id2.Value);
id1.Value.Should().NotBe(id3.Value);
id1.Value.Should().NotBe(id4.Value);
id1.Value.Should().NotBe(id5.Value);
}
#endregion
}