using XFEEDToolBox.Core.Galaxy;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public class GalaxyThargoidPresentationTests
{
[Test] public void PartialCacheRetainsPositiveTargetsWithoutTurningTheirLengthIntoWorldCounts()
{
var snapshot=new GalaxyThargoidSnapshot(true,true,false,[new(33,123),new(34,null),new(37,0)],
[new(0,9007199254740993,true,null)],[new(33<<8,33,0,9007199254740995,.5f)]);
var counts=GalaxyThargoidPresentation.Counts(snapshot);Check.That(counts.All(c=>c.Count is null));
Check.Equal(1,GalaxyThargoidPresentation.Signals(snapshot).Count);Check.Equal(1,GalaxyThargoidPresentation.Recommendations(snapshot).Count);
var ready=GalaxyThargoidPresentation.Counts(snapshot with{ResponseObserved=true});Check.Equal((uint?)123,ready[0].Count);Check.Equal((uint?)null,ready[1].Count);Check.Equal((uint?)0,ready[2].Count);
}
[Test] public void SignalIndexAndBooleanCannotInventATitanNameOrAnAffectedSystemCount()
{
var snapshot=new GalaxyThargoidSnapshot(true,false,false,[],[new(0,9007199254740993,true,null),new(1,216618994011,false,0)],[]);
var targets=GalaxyThargoidPresentation.Signals(snapshot);
Check.Equal(9007199254740993L,targets[0].SystemAddress);Check.Equal(0,targets[0].Id);Check.Equal("原信号 #0",targets[0].Label);Check.That(targets[0].Detail.Contains("未知"));
Check.Equal("Titan Leigong (已摧毁)",targets[1].Label);Check.That(targets[1].Detail.Contains("受影响星系:0"));Check.That(targets.All(t=>t.State is null));
}
[Test] public void RecommendationsRetainOriginalCallbackIdStateOrderAndActualProgress()
{
var source=new[]{new GalaxyThargoidRecommendation(33<<8,33,0,42,.8f),new(33<<8|1,33,1,43,.3f),new(35<<8,35,0,44,.6f)};
var targets=GalaxyThargoidPresentation.Recommendations(new(true,true,true,[],[],source));
Check.That(targets.Select(t=>t.Id).SequenceEqual(source.Select(s=>s.Id)));Check.That(targets.Select(t=>t.SystemAddress).SequenceEqual(new long[]{42,43,44}));
Check.Equal(33,targets[0].State);Check.Equal("Thargoid 控制 #1",targets[2].Label);Check.Equal(GalaxyThargoidTargetKind.Recommended,targets[0].Kind);
Check.Equal("原状态 99",GalaxyThargoidPresentation.StateName(99));
}
[Test] public void OnlyActualPublishedStatesClassifyTargetsAndDestroyedSignalsCannotReviveOldPublicTitanProofs()
{
var snapshot=new GalaxyThargoidSnapshot(true,false,false,[],[new(0,42,true,null),new(1,43,false,null)],[new(33<<8,33,0,44,.5f)]);
var states=GalaxyThargoidPresentation.ObservedStates(snapshot);Check.Equal((int?)36,states[42]);Check.Equal((int?)null,states[43]);Check.Equal((int?)33,states[44]);
var filter=new GalaxyMapFilter{Mode=GalaxyMapMode.ThargoidWar,Category=GalaxyFilterCategory.ThargoidWar,Values=new HashSet<string>{"titan"}};
var old=new GalacticSystem("Old public target",new(0,0,0)){Data=new(){ThargoidWar="Titan",Markers=["titan"],ConfirmedQueries=new HashSet<string>{filter.QueryKey},NativeThargoid=new("F1",42,null)}};
Check.That(!filter.Matches(old)&&filter.IsUnknown(old));Check.That((filter with{IncludeUnknown=true}).Matches(old));
var marker=filter with{Category=GalaxyFilterCategory.Markers};Check.That(!marker.Matches(old with{Data=old.Data with{ConfirmedQueries=new HashSet<string>{marker.QueryKey}}}));
var actual=old with{Data=old.Data with{NativeThargoid=new("F1",42,36)}};Check.That(filter.Matches(actual)&&marker.Matches(actual));
Check.That(actual.Data.ForNativeContext("F1",43,100).NativeThargoid is null);Check.That(actual.Data.ForAccount("F2").NativeThargoid is null);
Check.That(!System.Text.Json.JsonSerializer.Serialize(actual.Data).Contains("NativeThargoid"));
}
[Test] public void GridProjectionIsASeparateToolOptionAndOriginalConnectorsOnlyControlTheJumpNetwork()
{
var filter=GalaxyMapFilter.Default;Check.That(!filter.ShowGridStalks&&!filter.ShowLinks);
var import=GalaxyOriginalSettings.Parse("<Root><ShowSystemConnectors Value='1'/></Root>",filter);
Check.That(import.Filter.ShowLinks&&!import.Filter.ShowGridStalks);Check.Equal(filter.QueryKey,(filter with{ShowGridStalks=true}).QueryKey);
}
}
using XFEEDToolBox.Core.Galaxy;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public class GalaxyThargoidPresentationTests
{
[Test] public void PartialCacheRetainsPositiveTargetsWithoutTurningTheirLengthIntoWorldCounts()
{
var snapshot=new GalaxyThargoidSnapshot(true,true,false,[new(33,123),new(34,null),new(37,0)],
[new(0,9007199254740993,true,null)],[new(33<<8,33,0,9007199254740995,.5f)]);
var counts=GalaxyThargoidPresentation.Counts(snapshot);Check.That(counts.All(c=>c.Count is null));
Check.Equal(1,GalaxyThargoidPresentation.Signals(snapshot).Count);Check.Equal(1,GalaxyThargoidPresentation.Recommendations(snapshot).Count);
var ready=GalaxyThargoidPresentation.Counts(snapshot with{ResponseObserved=true});Check.Equal((uint?)123,ready[0].Count);Check.Equal((uint?)null,ready[1].Count);Check.Equal((uint?)0,ready[2].Count);
}
[Test] public void SignalIndexAndBooleanCannotInventATitanNameOrAnAffectedSystemCount()
{
var snapshot=new GalaxyThargoidSnapshot(true,false,false,[],[new(0,9007199254740993,true,null),new(1,216618994011,false,0)],[]);
var targets=GalaxyThargoidPresentation.Signals(snapshot);
Check.Equal(9007199254740993L,targets[0].SystemAddress);Check.Equal(0,targets[0].Id);Check.Equal("原信号 #0",targets[0].Label);Check.That(targets[0].Detail.Contains("未知"));
Check.Equal("Titan Leigong (已摧毁)",targets[1].Label);Check.That(targets[1].Detail.Contains("受影响星系:0"));Check.That(targets.All(t=>t.State is null));
}
[Test] public void RecommendationsRetainOriginalCallbackIdStateOrderAndActualProgress()
{
var source=new[]{new GalaxyThargoidRecommendation(33<<8,33,0,42,.8f),new(33<<8|1,33,1,43,.3f),new(35<<8,35,0,44,.6f)};
var targets=GalaxyThargoidPresentation.Recommendations(new(true,true,true,[],[],source));
Check.That(targets.Select(t=>t.Id).SequenceEqual(source.Select(s=>s.Id)));Check.That(targets.Select(t=>t.SystemAddress).SequenceEqual(new long[]{42,43,44}));
Check.Equal(33,targets[0].State);Check.Equal("Thargoid 控制 #1",targets[2].Label);Check.Equal(GalaxyThargoidTargetKind.Recommended,targets[0].Kind);
Check.Equal("原状态 99",GalaxyThargoidPresentation.StateName(99));
}
[Test] public void OnlyActualPublishedStatesClassifyTargetsAndDestroyedSignalsCannotReviveOldPublicTitanProofs()
{
var snapshot=new GalaxyThargoidSnapshot(true,false,false,[],[new(0,42,true,null),new(1,43,false,null)],[new(33<<8,33,0,44,.5f)]);
var states=GalaxyThargoidPresentation.ObservedStates(snapshot);Check.Equal((int?)36,states[42]);Check.Equal((int?)null,states[43]);Check.Equal((int?)33,states[44]);
var filter=new GalaxyMapFilter{Mode=GalaxyMapMode.ThargoidWar,Category=GalaxyFilterCategory.ThargoidWar,Values=new HashSet<string>{"titan"}};
var old=new GalacticSystem("Old public target",new(0,0,0)){Data=new(){ThargoidWar="Titan",Markers=["titan"],ConfirmedQueries=new HashSet<string>{filter.QueryKey},NativeThargoid=new("F1",42,null)}};
Check.That(!filter.Matches(old)&&filter.IsUnknown(old));Check.That((filter with{IncludeUnknown=true}).Matches(old));
var marker=filter with{Category=GalaxyFilterCategory.Markers};Check.That(!marker.Matches(old with{Data=old.Data with{ConfirmedQueries=new HashSet<string>{marker.QueryKey}}}));
var actual=old with{Data=old.Data with{NativeThargoid=new("F1",42,36)}};Check.That(filter.Matches(actual)&&marker.Matches(actual));
Check.That(actual.Data.ForNativeContext("F1",43,100).NativeThargoid is null);Check.That(actual.Data.ForAccount("F2").NativeThargoid is null);
Check.That(!System.Text.Json.JsonSerializer.Serialize(actual.Data).Contains("NativeThargoid"));
}
[Test] public void GridProjectionIsASeparateToolOptionAndOriginalConnectorsOnlyControlTheJumpNetwork()
{
var filter=GalaxyMapFilter.Default;Check.That(!filter.ShowGridStalks&&!filter.ShowLinks);
var import=GalaxyOriginalSettings.Parse("<Root><ShowSystemConnectors Value='1'/></Root>",filter);
Check.That(import.Filter.ShowLinks&&!import.Filter.ShowGridStalks);Check.Equal(filter.QueryKey,(filter with{ShowGridStalks=true}).QueryKey);
}
}