using FluentAssertions;
using MyNewProjectName.Domain.ValueObjects;

namespace MyNewProjectName.UnitTest.Domain;

public class ValueObjectTests
{
    private class TestValueObject : ValueObject
    {
        public string Value1 { get; }
        public int Value2 { get; }

        public TestValueObject(string value1, int value2)
        {
            Value1 = value1;
            Value2 = value2;
        }

        protected override IEnumerable<object?> GetEqualityComponents()
        {
            yield return Value1;
            yield return Value2;
        }
    }

    [Fact]
    public void ValueObjects_WithSameValues_ShouldBeEqual()
    {
        // Arrange
        var vo1 = new TestValueObject("test", 123);
        var vo2 = new TestValueObject("test", 123);

        // Act & Assert
        vo1.Should().Be(vo2);
        (vo1 == vo2).Should().BeTrue();
    }

    [Fact]
    public void ValueObjects_WithDifferentValues_ShouldNotBeEqual()
    {
        // Arrange
        var vo1 = new TestValueObject("test", 123);
        var vo2 = new TestValueObject("test", 456);

        // Act & Assert
        vo1.Should().NotBe(vo2);
        (vo1 != vo2).Should().BeTrue();
    }

    [Fact]
    public void GetHashCode_ShouldBeSameForEqualObjects()
    {
        // Arrange
        var vo1 = new TestValueObject("test", 123);
        var vo2 = new TestValueObject("test", 123);

        // Act & Assert
        vo1.GetHashCode().Should().Be(vo2.GetHashCode());
    }
}
