using Kompas.Mcp.Core.Drawings;

namespace Kompas.Mcp.Tests;

[Trait("Category", "Unit")]
public sealed class DimensionOrientationsTests
{
    [Theory]
    [InlineData("horizontal", DimensionOrientation.Horizontal)]
    [InlineData("vertical", DimensionOrientation.Vertical)]
    [InlineData("parallel", DimensionOrientation.Parallel)]
    [InlineData("ГОРИЗОНТАЛЬНЫЙ", DimensionOrientation.Horizontal)]
    [InlineData("  vertical ", DimensionOrientation.Vertical)]
    public void Parse_maps_known(string value, DimensionOrientation expected)
        => Assert.Equal(expected, DimensionOrientations.Parse(value));

    [Fact]
    public void Parse_throws_on_unknown()
        => Assert.Throws<ArgumentException>(() => DimensionOrientations.Parse("diagonal"));

    // ToKompas (→ ksLineDimensionOrientationEnum) намеренно НЕ покрыт unit-тестом: тестовый проект
    // не ссылается на Kompas6Constants (граница проекта). Маппинг тривиален и проверяется интеграцией
    // (horizontal → |X2-X1|, vertical → |Y2-Y1|).

    [Theory]
    [InlineData(0, 0)]
    [InlineData(90, Math.PI / 2)]
    [InlineData(180, Math.PI)]
    [InlineData(-45, -Math.PI / 4)]
    public void ToRadians_converts_degrees(double degrees, double expected)
        => Assert.Equal(expected, DimensionAngles.ToRadians(degrees), 9);

    [Fact]
    public void ToRadians_throws_on_non_finite()
        => Assert.Throws<ArgumentException>(() => DimensionAngles.ToRadians(double.NaN));
}
