using XFEEDToolBox.Core.Models;
using XFEEDToolBox.Core.Navigation;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public class StationDepartureTargetTests
{
private static PlayerState Player=>new(){InGame=true,Docked=true,MarketId=123,CurrentShipId=8,
Navigation=new(){CurrentSystemAddress=7},Ships=[new(){ShipId=8,HullHealth=1}]};
private static SystemLocation Dock=>new(2,17,"Only station","",7,SystemLocationCategory.Station,123,new(0,0,0),0,true,new('a',64));
private static CurrentSystemSnapshot Snapshot(params SystemLocation[] rows)=>new(7,"Single-station system",99,1,DateTimeOffset.UtcNow,rows);
[Test]public void SingleStationSystemCanDepartUsingActualDockWithoutInventingAnotherTarget()
{
var target=StationDepartureTarget.Resolve(Snapshot(Dock),Player);
Check.Equal(123L,target.MarketId!.Value);Check.Equal(17UL,target.BodyAddress);Check.Equal(2,target.NativeKey);Check.Equal(Dock.Identity,target.NativeIdentity);
var carrier=StationDepartureTarget.Resolve(Snapshot(Dock with{Category=SystemLocationCategory.Carrier}),Player);
Check.Equal(123L,carrier.MarketId!.Value);
}
[Test]public void OtherStationsCannotReplaceMissingDockAndTransitionOrThreatCannotAuthorizeDeparture()
{
Check.Throws<FlightTelemetryUnavailableException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock with{MarketId=456}),Player));
Check.Throws<FlightTelemetryUnavailableException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock) with{SystemAddress=9},Player));
Check.Throws<InvalidOperationException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock),Player with{Docked=false}));
Check.Throws<FlightThreatPauseException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock),Player with{Navigation=new(){CurrentSystemAddress=7,ExternalThreat=true}}));
}
}
using XFEEDToolBox.Core.Models;
using XFEEDToolBox.Core.Navigation;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public class StationDepartureTargetTests
{
private static PlayerState Player=>new(){InGame=true,Docked=true,MarketId=123,CurrentShipId=8,
Navigation=new(){CurrentSystemAddress=7},Ships=[new(){ShipId=8,HullHealth=1}]};
private static SystemLocation Dock=>new(2,17,"Only station","",7,SystemLocationCategory.Station,123,new(0,0,0),0,true,new('a',64));
private static CurrentSystemSnapshot Snapshot(params SystemLocation[] rows)=>new(7,"Single-station system",99,1,DateTimeOffset.UtcNow,rows);
[Test]public void SingleStationSystemCanDepartUsingActualDockWithoutInventingAnotherTarget()
{
var target=StationDepartureTarget.Resolve(Snapshot(Dock),Player);
Check.Equal(123L,target.MarketId!.Value);Check.Equal(17UL,target.BodyAddress);Check.Equal(2,target.NativeKey);Check.Equal(Dock.Identity,target.NativeIdentity);
var carrier=StationDepartureTarget.Resolve(Snapshot(Dock with{Category=SystemLocationCategory.Carrier}),Player);
Check.Equal(123L,carrier.MarketId!.Value);
}
[Test]public void OtherStationsCannotReplaceMissingDockAndTransitionOrThreatCannotAuthorizeDeparture()
{
Check.Throws<FlightTelemetryUnavailableException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock with{MarketId=456}),Player));
Check.Throws<FlightTelemetryUnavailableException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock) with{SystemAddress=9},Player));
Check.Throws<InvalidOperationException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock),Player with{Docked=false}));
Check.Throws<FlightThreatPauseException>(()=>StationDepartureTarget.Resolve(Snapshot(Dock),Player with{Navigation=new(){CurrentSystemAddress=7,ExternalThreat=true}}));
}
}