using RacePlannerApi.Models;

namespace backend.Tests.Utilities;

public static class TestDataFactory
{
    public static User CreateUser(
        string email = "test@example.com",
        string name = "Test User",
        UserRole role = UserRole.Participant,
        string password = "password123")
    {
        return new User
        {
            Id = Guid.NewGuid(),
            Email = email,
            Name = name,
            Role = role,
            PasswordHash = BCrypt.Net.BCrypt.HashPassword(password),
            CreatedAt = DateTime.UtcNow
        };
    }

    public static Event CreateEvent(
        string name = "Test Event",
        string description = "Test event description",
        DateTime? eventDate = null,
        string location = "Test Location",
        Guid? organizerId = null,
        EventStatus status = EventStatus.Draft)
    {
        return new Event
        {
            Id = Guid.NewGuid(),
            Name = name,
            Description = description,
            EventDate = eventDate ?? DateTime.UtcNow.AddDays(7),
            Location = location,
            OrganizerId = organizerId ?? Guid.NewGuid(),
            Status = status,
            Category = "Running",
            Tags = new List<string>(),
            MaxParticipants = 100,
            CreatedAt = DateTime.UtcNow,
            UpdatedAt = DateTime.UtcNow
        };
    }

    public static Registration CreateRegistration(
        Guid eventId,
        Guid participantId,
        RegistrationStatus status = RegistrationStatus.Pending)
    {
        return new Registration
        {
            Id = Guid.NewGuid(),
            EventId = eventId,
            ParticipantId = participantId,
            Status = status,
            EmergencyContact = "Emergency Contact: 123-456-7890",
            Category = "Open",
            CreatedAt = DateTime.UtcNow,
            Payments = new List<Payment>()
        };
    }

    public static Payment CreatePayment(
        Guid registrationId,
        decimal amount = 50.00m,
        PaymentMethod method = PaymentMethod.Cash)
    {
        return new Payment
        {
            Id = Guid.NewGuid(),
            RegistrationId = registrationId,
            Amount = amount,
            Method = method,
            TransactionId = method == PaymentMethod.Online ? Guid.NewGuid().ToString() : null,
            PaymentDate = DateTime.UtcNow,
            CreatedAt = DateTime.UtcNow
        };
    }

    public static Announcement CreateAnnouncement(
        Guid eventId,
        string title = "Test Announcement",
        string content = "Test announcement content",
        Guid? authorId = null)
    {
        return new Announcement
        {
            Id = Guid.NewGuid(),
            EventId = eventId,
            Title = title,
            Content = content,
            AuthorId = authorId ?? Guid.NewGuid(),
            CreatedAt = DateTime.UtcNow,
            UpdatedAt = DateTime.UtcNow
        };
    }
}
