using ColaFlow.Modules.ProjectManagement.Domain.Aggregates.ProjectAggregate;
using ColaFlow.Modules.ProjectManagement.Domain.ValueObjects;

namespace ColaFlow.Domain.Tests.Builders;

/// <summary>
/// Test Data Builder for creating test entities with default values.
/// Simplifies test setup by providing consistent test data.
/// </summary>
public static class TestDataBuilder
{
    /// <summary>
    /// Creates a test TenantId with a random GUID.
    /// </summary>
    public static TenantId CreateTestTenantId()
        => TenantId.From(Guid.NewGuid());

    /// <summary>
    /// Creates a test ProjectId with a random GUID.
    /// </summary>
    public static ProjectId CreateTestProjectId()
        => ProjectId.From(Guid.NewGuid());

    /// <summary>
    /// Creates a test UserId with a random GUID.
    /// </summary>
    public static UserId CreateTestUserId()
        => UserId.From(Guid.NewGuid());

    /// <summary>
    /// Creates a test EpicId with a random GUID.
    /// </summary>
    public static EpicId CreateTestEpicId()
        => EpicId.Create();

    /// <summary>
    /// Creates a test StoryId with a random GUID.
    /// </summary>
    public static StoryId CreateTestStoryId()
        => StoryId.Create();

    /// <summary>
    /// Creates a test Epic with default or provided values.
    /// </summary>
    public static Epic CreateTestEpic(
        TenantId? tenantId = null,
        string name = "Test Epic",
        string description = "Test Epic Description",
        ProjectId? projectId = null,
        UserId? createdBy = null)
    {
        return Epic.Create(
            tenantId ?? CreateTestTenantId(),
            name,
            description,
            projectId ?? CreateTestProjectId(),
            createdBy ?? CreateTestUserId());
    }

    /// <summary>
    /// Creates a test Story with default or provided values.
    /// </summary>
    public static Story CreateTestStory(
        TenantId? tenantId = null,
        string title = "Test Story",
        string description = "Test Story Description",
        EpicId? epicId = null,
        TaskPriority? priority = null,
        UserId? createdBy = null)
    {
        return Story.Create(
            tenantId ?? CreateTestTenantId(),
            title,
            description,
            epicId ?? CreateTestEpicId(),
            priority ?? TaskPriority.Medium,
            createdBy ?? CreateTestUserId());
    }

    /// <summary>
    /// Creates a test WorkTask with default or provided values.
    /// </summary>
    public static WorkTask CreateTestTask(
        TenantId? tenantId = null,
        string title = "Test Task",
        string description = "Test Task Description",
        StoryId? storyId = null,
        TaskPriority? priority = null,
        UserId? createdBy = null)
    {
        return WorkTask.Create(
            tenantId ?? CreateTestTenantId(),
            title,
            description,
            storyId ?? CreateTestStoryId(),
            priority ?? TaskPriority.Medium,
            createdBy ?? CreateTestUserId());
    }
}
