using XFEEDToolBox.Core.Navigation; using XFEEDToolBox.Core.Rendering; using XFEExtension.NetCore.XUnit.Attributes; namespace XFEEDToolBox.Test; [TestFixture] public sealed class LocalSystemMarkerLayoutTests { private static LocalSystemProjection Point(int id,SystemLocationCategory category,double x,double y)=>new(new(new(id,(ulong)id,"Object "+id,"",0,category,null,new(0,0,0),null,false,id.ToString()),new(0,0,0)),x,y,10,category==SystemLocationCategory.Star?80:12,new(0,0,1),false); [Test]public void MarkerDeclutteringDoesNotCoverTheStarSurfaceOrChangeAnyPhysicalProjection() { var star=Point(1,SystemLocationCategory.Star,500,400);var a=Point(2,SystemLocationCategory.Station,510,400);var b=Point(3,SystemLocationCategory.Carrier,511,400); var groups=LocalSystemMarkerLayout.Build([star,a,b],[star,a,b]);Check.Equal(1,groups.Count);Check.Equal(2,groups[0].Members.Count); Check.That(Math.Sqrt(Math.Pow(groups[0].Anchor.X-500,2)+Math.Pow(groups[0].Anchor.Y-400,2))>=100-1e-9); Check.Equal(510d,a.X);Check.Equal(500d,star.X);Check.That(groups[0].Members.Contains(a)&&groups[0].Members.Contains(b)); } [Test]public void FilteringOnlyMarkersRetainsAllModelsAndTheSelectedIconRepresentsItsCluster() { var star=Point(1,SystemLocationCategory.Star,500,400);var a=Point(2,SystemLocationCategory.Station,700,400);var b=Point(3,SystemLocationCategory.Carrier,701,400) with{Selected=true}; var groups=LocalSystemMarkerLayout.Build([star,a,b],[star,a,b]);Check.Equal(b.Node.Location.Identity,groups[0].Anchor.Node.Location.Identity); var filtered=LocalSystemMarkerLayout.Build([star,a,b],[star,a]);Check.Equal(1,filtered[0].Members.Count);Check.Equal(a.Node.Location.Identity,filtered[0].Anchor.Node.Location.Identity); Check.Equal(0,LocalSystemMarkerLayout.Build([star,a,b],[]).Count); } }