using System.Collections.Generic;
using Xunit;
using QuantEngine.Core.Domain;

namespace QuantEngine.Core.Tests;

public class FactorWeightCalibratorTests
{
    [Fact]
    public void CalibrateWeights_WithValidInputs_SatisfiesBoundsAndShrinkage()
    {
        // Arrange
        var calibrator = new FactorWeightCalibrator();
        var baseWeights = new Dictionary<string, decimal>
        {
            { "F01_MOMENTUM", 0.30m },
            { "F02_VOLATILITY", 0.20m }
        };
        var rawWeights = new Dictionary<string, decimal>
        {
            { "F01_MOMENTUM", 0.60m }, // Out of bounds raw
            { "F02_VOLATILITY", 0.10m }
        };

        // Act
        var result = calibrator.CalibrateWeights("SS001_v1", baseWeights, rawWeights);

        // Assert
        Assert.Equal("SS001_v1", result.FormulaId);
        Assert.Equal("PASS", result.GateStatus);
        Assert.True(result.WeightsWithinBounds);
        Assert.True(result.OosComparisonReported);
        Assert.Equal(0.45m, result.Weights[0].CalibratedWeight); // Clamped to 0.30 * 1.5 = 0.45
    }
}
