using FluentAssertions;

public class News2CalculatorTests
{
    // --- Respiratory rate ---
    [Theory]
    [InlineData(8,  3)]   // ≤8
    [InlineData(9,  1)]   // 9-11
    [InlineData(11, 1)]
    [InlineData(12, 0)]   // 12-20
    [InlineData(20, 0)]
    [InlineData(21, 2)]   // 21-24
    [InlineData(24, 2)]
    [InlineData(25, 3)]   // ≥25
    public void ScoreRespRate(int value, int expected) =>
        News2Calculator.ScoreRespRate(value).Should().Be(expected);

    // --- SpO2 (Scale 1) ---
    [Theory]
    [InlineData(91, 3)]
    [InlineData(92, 2)]
    [InlineData(93, 2)]
    [InlineData(94, 1)]
    [InlineData(95, 1)]
    [InlineData(96, 0)]
    [InlineData(99, 0)]
    public void ScoreSpo2(int value, int expected) =>
        News2Calculator.ScoreSpo2(value).Should().Be(expected);

    // --- Systolic BP ---
    [Theory]
    [InlineData(90,  3)]
    [InlineData(91,  2)]
    [InlineData(100, 2)]
    [InlineData(101, 1)]
    [InlineData(110, 1)]
    [InlineData(111, 0)]
    [InlineData(219, 0)]
    [InlineData(220, 3)]
    public void ScoreSystolicBp(int value, int expected) =>
        News2Calculator.ScoreSystolicBp(value).Should().Be(expected);

    // --- Heart rate ---
    [Theory]
    [InlineData(40,  3)]
    [InlineData(41,  1)]
    [InlineData(50,  1)]
    [InlineData(51,  0)]
    [InlineData(90,  0)]
    [InlineData(91,  1)]
    [InlineData(110, 1)]
    [InlineData(111, 2)]
    [InlineData(130, 2)]
    [InlineData(131, 3)]
    public void ScoreHeartRate(int value, int expected) =>
        News2Calculator.ScoreHeartRate(value).Should().Be(expected);

    // --- AVPU ---
    [Theory]
    [InlineData(0, 0)]   // Alert
    [InlineData(1, 3)]   // Voice
    [InlineData(2, 3)]   // Pain
    [InlineData(3, 3)]   // Unresponsive
    public void ScoreConsciousness(int value, int expected) =>
        News2Calculator.ScoreConsciousness(value).Should().Be(expected);

    // --- Temperature ---
    [Theory]
    [InlineData(35.0, 3)]
    [InlineData(35.1, 1)]
    [InlineData(36.0, 1)]
    [InlineData(36.1, 0)]
    [InlineData(38.0, 0)]
    [InlineData(38.1, 1)]
    [InlineData(39.0, 1)]
    [InlineData(39.1, 2)]
    public void ScoreTemperature(double value, int expected) =>
        News2Calculator.ScoreTemperature((decimal)value).Should().Be(expected);

    // --- Supplemental O2 ---
    [Theory]
    [InlineData(0, 0)]
    [InlineData(1, 2)]
    public void ScoreSupplementalO2(int value, int expected) =>
        News2Calculator.ScoreSupplementalO2(value).Should().Be(expected);

    // --- Risk level determination ---
    [Theory]
    [InlineData(0,  false, "LOW")]
    [InlineData(4,  false, "LOW")]
    [InlineData(3,  true,  "LOW_MEDIUM")]   // single param = 3
    [InlineData(5,  false, "MEDIUM")]
    [InlineData(6,  true,  "MEDIUM")]       // 5-6 is MEDIUM regardless of single-3
    [InlineData(7,  false, "HIGH")]
    [InlineData(12, true,  "HIGH")]
    public void DetermineRiskLevel(int total, bool singleThree, string expected) =>
        News2Calculator.DetermineRiskLevel(total, singleThree).Should().Be(expected);

    // --- All 7 keys returned ---
    [Fact]
    public void AllParameterKeys_ReturnsSeven()
    {
        var keys = News2Calculator.AllParameterKeys(Guid.NewGuid());
        keys.Should().HaveCount(7);
        keys.Select(k => k.ToString()).Should().OnlyHaveUniqueItems();
    }
}