using RioJoy.Core.Calibration;
using RioJoy.Core.Editing;
using Xunit;

namespace RioJoy.Core.Tests.Editing;

public class AxisGaugesTests
{
    [Theory]
    [InlineData(0, 0.0)]
    [InlineData(AxisOutputs.Max, 1.0)]
    [InlineData(-500, 0.0)]                // clamps below range
    [InlineData(AxisOutputs.Max + 500, 1.0)] // clamps above range
    public void Fraction_MapsAndClamps(int value, double expected) =>
        Assert.Equal(expected, AxisGauges.Fraction(value), precision: 6);

    [Fact]
    public void Fraction_Center_IsHalf() =>
        Assert.Equal(0.5, AxisGauges.Fraction(AxisOutputs.Center), precision: 3);

    [Theory]
    [InlineData(AxisOutputs.Center, 0.0)]
    [InlineData(0, -1.0)]
    [InlineData(-500, -1.0)]                 // clamps below range
    [InlineData(AxisOutputs.Max + 500, 1.0)] // clamps above range
    public void Deflection_MapsAndClamps(int value, double expected) =>
        Assert.Equal(expected, AxisGauges.Deflection(value), precision: 6);

    [Fact]
    public void Deflection_Max_IsFullRight() =>
        Assert.Equal(1.0, AxisGauges.Deflection(AxisOutputs.Max), precision: 3);
}
