XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using XFEEDToolBox.Core.Navigation;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public class ThermalCurveTests
{
    private static readonly DateTimeOffset Now=DateTimeOffset.Parse("2026-10-21T06:00:00Z");
    private static ShipThermalCalibration Model=>new(){Verified=true,GameSha256="build",LoadoutFingerprint="fit",StarBodyId=1,ExpiresAt=Now.AddMinutes(20),
        MinimumHeat=0,MaximumHeat=100,ChargingGainUpperPerSecond=11,ChargedHoldGainUpperPerSecond=11,ChargeDurationUpperSeconds=30,
        DistanceBands=[new(100,200,4,0)],CoolingCurve=new(0,20,0,100,2),Evidence="Synthetic analytic quadratic-ODE fixture"};
    [Test] public void QuadraticCoolingPredictionBoundsAnIndependentAnalyticSolution()
    {
        var forecast=ThermalPredictor.Predict(Model,"build","fit",1,40,110,180,30,0,Now);
        const double gain=15,coefficient=.002;var equilibrium=Math.Sqrt(gain/coefficient);
        var exact=equilibrium*Math.Tanh(Math.Atanh(40/equilibrium)+Math.Sqrt(gain*coefficient)*30);
        Check.That(forecast.Known&&forecast.AllowsCharging);
        Check.That(forecast.PeakPercent>=exact-1e-8&&forecast.PeakPercent<=exact+.1,$"Expected conservative bound near {exact}; got {forecast.PeakPercent}");
        var held=ThermalPredictor.Predict(Model,"build","fit",1,40,110,180,30,120,Now);
        Check.That(held.Known&&held.AllowsCharging&&held.PeakPercent>=forecast.PeakPercent&&held.PeakPercent<=equilibrium+.1);
    }
    [Test] public void InvalidOrTooLongNativeCurveCannotAuthorizeCharging()
    {
        foreach(var curve in new[]{new ThermalCoolingCurve(0,double.NaN,0,100,2),new(2,1,0,100,2),new(0,20,100,0,2),new(0,20,0,100,.5)})
            Check.That(!ThermalPredictor.Predict(Model with{CoolingCurve=curve},"build","fit",1,40,110,180,30,0,Now).Known);
        Check.That(!ThermalPredictor.Predict(Model,"build","fit",1,40,110,180,30,580,Now).Known);
        var hot=ThermalPredictor.Predict(Model with{DistanceBands=[new(100,200,15,0)]},"build","fit",1,70,110,180,30,0,Now);
        Check.That(!hot.AllowsCharging);
    }
}