using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public class GalaxyForcedPointLodTests
{
private static readonly GalacticSystem Published=new("Published policy fixture",new(0,0,0),1,"G");
private static GalaxyCatalogueSelection Selection()=>new(GalaxyOriginalCatalogueLod.Create(new(1000,0,1000),1,32,.001,1,0),new(0,0,0))
{PointOverrides=new(42,1,0,0,true,false,[new(1,1,false,false,Published.Position,Published.Name,"G",null)],[])};
[Test] public void AKindZeroPublishedPointInTheMiddleOfAnOverflowingTileReservesItsOwnBudgetSlot()
{
const int count=10000,index=123,budget=64;
var selection=Selection();var filter=new GalaxyMapFilter{Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.StarClass,Values=new HashSet<string>{"g"}};
Check.That(selection.IsForced(Published)&&filter.Matches(Published));
var priority=GalaxyMapLod.IsPriority(Published,selection,filter.Matches(Published),retainedMarker:false);Check.That(priority);
// Confirm that this interior source-order point is dropped by ordinary
// fair sampling; a last-row fixture would always be sampled anyway.
var baseline=new GalaxyMapLod();baseline.Begin(1000,800,budget);
for(var i=0;i<count;i++)baseline.Count(500,400);baseline.Seal();var baselineTarget=false;
for(var i=0;i<count;i++){var accepted=baseline.Accept(500,400);if(i==index)baselineTarget=accepted;}
Check.That(!baselineTarget);
foreach(var actualBudget in new[]{budget,128})
{
var lod=new GalaxyMapLod();lod.Begin(1000,800,actualBudget);
for(var i=0;i<count;i++)lod.Count(500,400,i==index&&priority);lod.Seal();
var kept=0;var target=false;
for(var i=0;i<count;i++)if(lod.Accept(500,400,i==index&&priority)){kept++;if(i==index)target=true;}
Check.That(target);Check.Equal(actualBudget,kept);
}
}
[Test] public void ForcePriorityRequiresExactCurrentIdentityAndCannotRestoreAnIneligibleQueryOrHiddenPoint()
{
var selection=Selection();
var negative=new GalaxyMapFilter{Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.StarClass,Values=new HashSet<string>{"k"}};
Check.That(selection.Contains(Published)&&!negative.Matches(Published));
Check.That(!GalaxyMapLod.IsPriority(Published,selection,negative.Matches(Published)));
Check.That(!GalaxyMapLod.IsPriority(Published,selection,false,retainedMarker:true));
Check.That(!GalaxyMapLod.IsPriority(Published with{Position=new(1,0,0)},selection,true));
Check.That(!GalaxyMapLod.IsPriority(Published with{SystemAddress=2},selection,true));
Check.That(!GalaxyMapLod.IsPriority(Published,selection with{PointOverrides=null},true));
Check.That(!GalaxyMapLod.IsPriority(Published,null,true));
Check.That(GalaxyMapLod.IsPriority(Published,null,true,retainedMarker:true));
// Pending=false is a consumed publication, not lost priority; neither
// changing kind nor creating a navigation marker is required.
Check.That(selection.PointOverrides!.Overrides[1].Pending==false&&GalaxyMapLod.IsPriority(Published,selection,true));
}
}
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public class GalaxyForcedPointLodTests
{
private static readonly GalacticSystem Published=new("Published policy fixture",new(0,0,0),1,"G");
private static GalaxyCatalogueSelection Selection()=>new(GalaxyOriginalCatalogueLod.Create(new(1000,0,1000),1,32,.001,1,0),new(0,0,0))
{PointOverrides=new(42,1,0,0,true,false,[new(1,1,false,false,Published.Position,Published.Name,"G",null)],[])};
[Test] public void AKindZeroPublishedPointInTheMiddleOfAnOverflowingTileReservesItsOwnBudgetSlot()
{
const int count=10000,index=123,budget=64;
var selection=Selection();var filter=new GalaxyMapFilter{Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.StarClass,Values=new HashSet<string>{"g"}};
Check.That(selection.IsForced(Published)&&filter.Matches(Published));
var priority=GalaxyMapLod.IsPriority(Published,selection,filter.Matches(Published),retainedMarker:false);Check.That(priority);
// Confirm that this interior source-order point is dropped by ordinary
// fair sampling; a last-row fixture would always be sampled anyway.
var baseline=new GalaxyMapLod();baseline.Begin(1000,800,budget);
for(var i=0;i<count;i++)baseline.Count(500,400);baseline.Seal();var baselineTarget=false;
for(var i=0;i<count;i++){var accepted=baseline.Accept(500,400);if(i==index)baselineTarget=accepted;}
Check.That(!baselineTarget);
foreach(var actualBudget in new[]{budget,128})
{
var lod=new GalaxyMapLod();lod.Begin(1000,800,actualBudget);
for(var i=0;i<count;i++)lod.Count(500,400,i==index&&priority);lod.Seal();
var kept=0;var target=false;
for(var i=0;i<count;i++)if(lod.Accept(500,400,i==index&&priority)){kept++;if(i==index)target=true;}
Check.That(target);Check.Equal(actualBudget,kept);
}
}
[Test] public void ForcePriorityRequiresExactCurrentIdentityAndCannotRestoreAnIneligibleQueryOrHiddenPoint()
{
var selection=Selection();
var negative=new GalaxyMapFilter{Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.StarClass,Values=new HashSet<string>{"k"}};
Check.That(selection.Contains(Published)&&!negative.Matches(Published));
Check.That(!GalaxyMapLod.IsPriority(Published,selection,negative.Matches(Published)));
Check.That(!GalaxyMapLod.IsPriority(Published,selection,false,retainedMarker:true));
Check.That(!GalaxyMapLod.IsPriority(Published with{Position=new(1,0,0)},selection,true));
Check.That(!GalaxyMapLod.IsPriority(Published with{SystemAddress=2},selection,true));
Check.That(!GalaxyMapLod.IsPriority(Published,selection with{PointOverrides=null},true));
Check.That(!GalaxyMapLod.IsPriority(Published,null,true));
Check.That(GalaxyMapLod.IsPriority(Published,null,true,retainedMarker:true));
// Pending=false is a consumed publication, not lost priority; neither
// changing kind nor creating a navigation marker is required.
Check.That(selection.PointOverrides!.Overrides[1].Pending==false&&GalaxyMapLod.IsPriority(Published,selection,true));
}
}