using FluentAssertions;
using CatalogService.Domain.AggregatesModel.ProductAggregate;
using CatalogService.Domain.Exceptions;
using Xunit;

namespace CatalogService.UnitTests.Domain;

/// <summary>
/// EN: Unit tests for product aggregate behavior.
/// VI: Unit tests cho hành vi aggregate sản phẩm.
/// </summary>
public class ProductAggregateTests
{
    [Fact]
    public void CreateProduct_WithValidData_ShouldBeActive()
    {
        // Act
        var product = new Product(Guid.NewGuid(), "Cà phê sữa", 35000m, ProductType.PreparedFood);

        // Assert
        product.Name.Should().Be("Cà phê sữa");
        product.Price.Should().Be(35000m);
        product.Type.Should().Be(ProductType.PreparedFood);
        product.IsActive.Should().BeTrue();
    }

    [Fact]
    public void UpdateInfo_ShouldUpdateNameAndPrice()
    {
        // Arrange
        var product = new Product(Guid.NewGuid(), "Trà đào", 30000m, ProductType.PreparedFood);

        // Act
        product.UpdateInfo("Trà đào cam sả", "Best seller", 42000m);

        // Assert
        product.Name.Should().Be("Trà đào cam sả");
        product.Description.Should().Be("Best seller");
        product.Price.Should().Be(42000m);
    }

    [Fact]
    public void Activate_WhenAlreadyActive_ShouldThrowDomainException()
    {
        // Arrange
        var product = new Product(Guid.NewGuid(), "Combo lunch", 89000m, ProductType.Physical);

        // Act
        var action = () => product.Activate();

        // Assert
        action.Should().Throw<DomainException>();
    }
}
