using KArtSell.Modules.SignalEngine.Domain;

namespace KArtSell.SignalEngine.UnitTests;

public sealed class SellPolicyContractTests
{
    [Fact]
    public void Policy_ids_and_priorities_are_unique_and_strictly_ordered()
    {
        var definitions = SellPolicyContract.Definitions;

        Assert.Equal(definitions.Count, definitions.Select(x => x.PolicyId).Distinct().Count());
        Assert.Equal(definitions.Count, definitions.Select(x => x.Priority).Distinct().Count());
        Assert.True(definitions.Zip(definitions.Skip(1), (left, right) => left.Priority > right.Priority).All(x => x));
    }

    [Fact]
    public void Approved_ratios_and_thresholds_remain_within_documented_ranges()
    {
        Assert.InRange(SellPolicyContract.HardImpairmentSellRatioOfLot, 0.80m, 1.00m);
        Assert.InRange(SellPolicyContract.GapFloorSellRatioOfLot, 0.30m, 0.50m);
        Assert.InRange(SellPolicyContract.TwoCloseSellRatioOfLot, 0.15m, 0.25m);
        Assert.InRange(SellPolicyContract.OpportunityMinimumSellRatioOfLot, 0.10m, 0.25m);
        Assert.InRange(SellPolicyContract.OpportunityMaximumSellRatioOfLot, 0.10m, 0.25m);
        Assert.True(SellPolicyContract.OpportunityMinimumSellRatioOfLot <= SellPolicyContract.OpportunityMaximumSellRatioOfLot);
    }
}
