using DansoriEQ.Core.Eq;
using DansoriEQ.Core.Profiles;
using Xunit;

namespace DansoriEQ.Core.Tests;

public class AutoEqParserTests
{
    [Fact]
    public void ParsesPreampAndOnlyEnabledFilters()
    {
        var text =
@"Preamp: -6.8 dB
Filter 1: ON PK Fc 105 Hz Gain 4.2 dB Q 0.70
Filter 2: ON LSC Fc 60 Hz Gain 3.0 dB Q 0.71
Filter 3: OFF PK Fc 200 Hz Gain 2.0 dB Q 1.0";

        var s = AutoEqParser.Parse(text);

        Assert.Equal(-6.8, s.PreampDb, 3);
        Assert.Equal(2, s.Filters.Count);                 // Filter 3 (OFF) is skipped
        Assert.Equal(FilterType.Peaking, s.Filters[0].Type);
        Assert.Equal(105, s.Filters[0].Fc, 3);
        Assert.Equal(4.2, s.Filters[0].GainDb, 3);
        Assert.Equal(0.70, s.Filters[0].Q, 3);
        Assert.Equal(FilterType.LowShelfSlope, s.Filters[1].Type);
    }

    [Fact]
    public void EmptyText_YieldsEmptyState()
    {
        var s = AutoEqParser.Parse("");
        Assert.Equal(0, s.PreampDb, 3);
        Assert.Empty(s.Filters);
    }
}

