using System.Text.Json;
using System.Text.Json.Nodes;
using XFEEDToolBox.Core.Navigation;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public sealed class ScoStoppedBurstTests
{
private static readonly DateTimeOffset Now=DateTimeOffset.Parse("2026-10-26T04:22:05.725Z");
private static SystemFlightFrame Frame=>new(){InGame=true,GeometryVerified=true,ShipEntity=12,ReferenceWorld=24,Mode=LocalFlightMode.Supercruise,ObservedAt=Now};
private static JsonObject Status()
{
var at=Now.ToUnixTimeMilliseconds();var gate=new{identityVerified=true,targetVerified=true,geometryVerified=true,emergency=false,damageSeen=false,assistEnabled=false,collisionCourse=false,rawFsdState=2,evaluatedAtUnixMilliseconds=at};
return JsonSerializer.SerializeToNode(new{owned=false,sampleReady=true,sample=new{verified=true,stableFsd=true,inSupercruise=true,playerOverride=false,healthEmergency=false,active=false,
entityId="12",referenceWorldAddress="24",rawFsdState=2,state=3,observedAtUnixMilliseconds=at,hullFraction=1,heatPercent=29},lastGate=gate,
lastOriginalStop=new{owner="owner",startRequestId="start",entityId="12",referenceWorldAddress="24",selectionGeneration=1,argument=false,
observedAtUnixMilliseconds=at,reason="flight-state",nativeMethodCalled=false,stateBefore=3,stateAfter=3,gate}})!.AsObject();
}
private static bool Accept(JsonObject status,SystemFlightFrame? frame=null)=>ScoStoppedBurst.CanContinue(JsonSerializer.SerializeToElement(status),"owner","start",1,frame??Frame,Now);
[Test]public void AVerifiedOriginalSelfStopKeepsOrdinaryControlAfterTheShortBowenWarmup()
{Check.That(Accept(Status()));}
[Test]public void AConfirmedOwnedThermalStopAlsoKeepsOrdinaryFlightWhenHeatIsBelowTheCeiling()
{
var row=Status();row["sample"]!["heatPercent"]=98;row["lastOriginalStop"]!["reason"]="heat";row["lastOriginalStop"]!["nativeMethodCalled"]=true;
row["lastOriginalStop"]!["nativeMethodRva"]="2eaacd0";row["lastOriginalStop"]!["stateBefore"]=2;Check.That(Accept(row));
}
[Test]public void ActiveUnknownForeignStaleOrDamagedStateStillRequiresTelemetryRecovery()
{
foreach(var change in new Action<JsonObject>[]
{
row=>row["owned"]=true,row=>row["sample"]!["state"]=2,row=>row["sample"]!["active"]=true,
row=>row["sample"]!["playerOverride"]=true,row=>row["sample"]!["healthEmergency"]=true,row=>row["sample"]!["hullFraction"]=0,
row=>row["sample"]!["heatPercent"]=100,row=>row["sample"]!["observedAtUnixMilliseconds"]=Now.AddSeconds(-1).ToUnixTimeMilliseconds(),
row=>row["lastOriginalStop"]!["owner"]="other",row=>row["lastOriginalStop"]!["startRequestId"]="other",row=>row["lastOriginalStop"]!["selectionGeneration"]=2,
row=>row["lastOriginalStop"]!["entityId"]="99",row=>row["lastOriginalStop"]!["referenceWorldAddress"]="99",
row=>row["lastOriginalStop"]!["reason"]="expired",row=>row["lastOriginalStop"]!["reason"]="health",
row=>row["lastOriginalStop"]!["stateBefore"]=2,row=>row["lastOriginalStop"]!["gate"]!["rawFsdState"]=1,
row=>row["lastOriginalStop"]!["gate"]!["damageSeen"]=true,row=>row["lastGate"]!["collisionCourse"]=true,
row=>row["lastGate"]!["assistEnabled"]=true,row=>row["lastGate"]!["geometryVerified"]=false,
row=>row["sample"]!.AsObject().Remove("healthEmergency"),row=>row["lastGate"]=null
})
{var row=Status();change(row);Check.That(!Accept(row),row.ToJsonString());}
Check.That(!Accept(Status(),Frame with{PlayerOverride=true}));Check.That(!Accept(Status(),Frame with{ExternalThreat=true}));
}
}
using System.Text.Json;
using System.Text.Json.Nodes;
using XFEEDToolBox.Core.Navigation;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public sealed class ScoStoppedBurstTests
{
private static readonly DateTimeOffset Now=DateTimeOffset.Parse("2026-10-26T04:22:05.725Z");
private static SystemFlightFrame Frame=>new(){InGame=true,GeometryVerified=true,ShipEntity=12,ReferenceWorld=24,Mode=LocalFlightMode.Supercruise,ObservedAt=Now};
private static JsonObject Status()
{
var at=Now.ToUnixTimeMilliseconds();var gate=new{identityVerified=true,targetVerified=true,geometryVerified=true,emergency=false,damageSeen=false,assistEnabled=false,collisionCourse=false,rawFsdState=2,evaluatedAtUnixMilliseconds=at};
return JsonSerializer.SerializeToNode(new{owned=false,sampleReady=true,sample=new{verified=true,stableFsd=true,inSupercruise=true,playerOverride=false,healthEmergency=false,active=false,
entityId="12",referenceWorldAddress="24",rawFsdState=2,state=3,observedAtUnixMilliseconds=at,hullFraction=1,heatPercent=29},lastGate=gate,
lastOriginalStop=new{owner="owner",startRequestId="start",entityId="12",referenceWorldAddress="24",selectionGeneration=1,argument=false,
observedAtUnixMilliseconds=at,reason="flight-state",nativeMethodCalled=false,stateBefore=3,stateAfter=3,gate}})!.AsObject();
}
private static bool Accept(JsonObject status,SystemFlightFrame? frame=null)=>ScoStoppedBurst.CanContinue(JsonSerializer.SerializeToElement(status),"owner","start",1,frame??Frame,Now);
[Test]public void AVerifiedOriginalSelfStopKeepsOrdinaryControlAfterTheShortBowenWarmup()
{Check.That(Accept(Status()));}
[Test]public void AConfirmedOwnedThermalStopAlsoKeepsOrdinaryFlightWhenHeatIsBelowTheCeiling()
{
var row=Status();row["sample"]!["heatPercent"]=98;row["lastOriginalStop"]!["reason"]="heat";row["lastOriginalStop"]!["nativeMethodCalled"]=true;
row["lastOriginalStop"]!["nativeMethodRva"]="2eaacd0";row["lastOriginalStop"]!["stateBefore"]=2;Check.That(Accept(row));
}
[Test]public void ActiveUnknownForeignStaleOrDamagedStateStillRequiresTelemetryRecovery()
{
foreach(var change in new Action<JsonObject>[]
{
row=>row["owned"]=true,row=>row["sample"]!["state"]=2,row=>row["sample"]!["active"]=true,
row=>row["sample"]!["playerOverride"]=true,row=>row["sample"]!["healthEmergency"]=true,row=>row["sample"]!["hullFraction"]=0,
row=>row["sample"]!["heatPercent"]=100,row=>row["sample"]!["observedAtUnixMilliseconds"]=Now.AddSeconds(-1).ToUnixTimeMilliseconds(),
row=>row["lastOriginalStop"]!["owner"]="other",row=>row["lastOriginalStop"]!["startRequestId"]="other",row=>row["lastOriginalStop"]!["selectionGeneration"]=2,
row=>row["lastOriginalStop"]!["entityId"]="99",row=>row["lastOriginalStop"]!["referenceWorldAddress"]="99",
row=>row["lastOriginalStop"]!["reason"]="expired",row=>row["lastOriginalStop"]!["reason"]="health",
row=>row["lastOriginalStop"]!["stateBefore"]=2,row=>row["lastOriginalStop"]!["gate"]!["rawFsdState"]=1,
row=>row["lastOriginalStop"]!["gate"]!["damageSeen"]=true,row=>row["lastGate"]!["collisionCourse"]=true,
row=>row["lastGate"]!["assistEnabled"]=true,row=>row["lastGate"]!["geometryVerified"]=false,
row=>row["sample"]!.AsObject().Remove("healthEmergency"),row=>row["lastGate"]=null
})
{var row=Status();change(row);Check.That(!Accept(row),row.ToJsonString());}
Check.That(!Accept(Status(),Frame with{PlayerOverride=true}));Check.That(!Accept(Status(),Frame with{ExternalThreat=true}));
}
}