using XFEEDToolBox.Core.Galaxy;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public sealed class GalaxyStateFilterChoicesTests
{
private static GalaxyMapFilter Original(params string[] names)=>new(){Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.State,RequireOriginalStateFacts=true,
OriginalRouteOptionKeys=new Dictionary<GalaxyFilterCategory,IReadOnlySet<string>>{{GalaxyFilterCategory.State,names.ToHashSet()}}};
[Test] public void ActualStateNamesExpandPastTheStaticBgsListWithoutInventingNumericEnumsOrPublicRows()
{
var filter=Original("None","War","Frontline","UNPOPULATED","SystemStateThargoidStronghold","VerifiedFutureSetting");
var choices=GalaxyStateFilterChoices.FromOriginal(filter)!;
Check.That(choices.Select(c=>c.Key).ToHashSet().SetEquals(["none","war","frontline","unpopulated","systemstatethargoidstronghold","verifiedfuturesetting"]));
Check.That(!choices.Any(c=>c.Key=="boom"));
Check.Equal(GalaxyFilterDefinitions.All.First(d=>d.Category==GalaxyFilterCategory.State).Choices.Single(c=>c.Key=="war").Label,choices.Single(c=>c.Key=="war").Label);
Check.Equal("verifiedfuturesetting",choices.Single(c=>c.Key=="verifiedfuturesetting").Label);
}
[Test] public void NullSelectionExpandsTheFullDynamicUniverseWhenOneRowIsUnchecked()
{
var filter=Original("None","War","Frontline","Unpopulated");var choices=GalaxyStateFilterChoices.FromOriginal(filter)!;
// The UI may show only War after searching; Select receives the same
// complete source list used before that presentation-only search.
var selected=GalaxyStateFilterChoices.Select(null,choices,"War",false);
Check.That(selected.SetEquals(["none","frontline","unpopulated"]));
var one=GalaxyStateFilterChoices.Select(new HashSet<string>(),choices,"Frontline",true);
Check.That(one.SetEquals(["frontline"]));
Check.That(GalaxyStateFilterChoices.Select(selected,choices,"War",true).SetEquals(choices.Select(c=>c.Key)));
}
[Test] public void SavedSelectionsAndMeasuredKeysStayEditableWithoutAddingUnrelatedStaticOptions()
{
var filter=Original("None","Unpopulated") with{Values=new HashSet<string>{"savedstate"}};
var choices=GalaxyStateFilterChoices.FromOriginal(filter,["sourceObservedState"] )!;
Check.That(choices.Select(c=>c.Key).ToHashSet().SetEquals(["none","unpopulated","savedstate","sourceobservedstate"]));
var values=GalaxyStateFilterChoices.Select(filter.Values,choices,"Unpopulated",true);
Check.That(values.SetEquals(["savedstate","unpopulated"])&&filter.Values!.SetEquals(["savedstate"]));
Check.That(GalaxyStateFilterChoices.FromOriginal(filter with{RequireOriginalStateFacts=false}) is null);
Check.That(GalaxyStateFilterChoices.FromOriginal(filter with{Category=GalaxyFilterCategory.Government}) is null);
Check.That(GalaxyStateFilterChoices.FromOriginal(Original()) is null);
}
}
using XFEEDToolBox.Core.Galaxy;
using XFEExtension.NetCore.XUnit.Attributes;
namespace XFEEDToolBox.Test;
[TestFixture]
public sealed class GalaxyStateFilterChoicesTests
{
private static GalaxyMapFilter Original(params string[] names)=>new(){Mode=GalaxyMapMode.Map,Category=GalaxyFilterCategory.State,RequireOriginalStateFacts=true,
OriginalRouteOptionKeys=new Dictionary<GalaxyFilterCategory,IReadOnlySet<string>>{{GalaxyFilterCategory.State,names.ToHashSet()}}};
[Test] public void ActualStateNamesExpandPastTheStaticBgsListWithoutInventingNumericEnumsOrPublicRows()
{
var filter=Original("None","War","Frontline","UNPOPULATED","SystemStateThargoidStronghold","VerifiedFutureSetting");
var choices=GalaxyStateFilterChoices.FromOriginal(filter)!;
Check.That(choices.Select(c=>c.Key).ToHashSet().SetEquals(["none","war","frontline","unpopulated","systemstatethargoidstronghold","verifiedfuturesetting"]));
Check.That(!choices.Any(c=>c.Key=="boom"));
Check.Equal(GalaxyFilterDefinitions.All.First(d=>d.Category==GalaxyFilterCategory.State).Choices.Single(c=>c.Key=="war").Label,choices.Single(c=>c.Key=="war").Label);
Check.Equal("verifiedfuturesetting",choices.Single(c=>c.Key=="verifiedfuturesetting").Label);
}
[Test] public void NullSelectionExpandsTheFullDynamicUniverseWhenOneRowIsUnchecked()
{
var filter=Original("None","War","Frontline","Unpopulated");var choices=GalaxyStateFilterChoices.FromOriginal(filter)!;
// The UI may show only War after searching; Select receives the same
// complete source list used before that presentation-only search.
var selected=GalaxyStateFilterChoices.Select(null,choices,"War",false);
Check.That(selected.SetEquals(["none","frontline","unpopulated"]));
var one=GalaxyStateFilterChoices.Select(new HashSet<string>(),choices,"Frontline",true);
Check.That(one.SetEquals(["frontline"]));
Check.That(GalaxyStateFilterChoices.Select(selected,choices,"War",true).SetEquals(choices.Select(c=>c.Key)));
}
[Test] public void SavedSelectionsAndMeasuredKeysStayEditableWithoutAddingUnrelatedStaticOptions()
{
var filter=Original("None","Unpopulated") with{Values=new HashSet<string>{"savedstate"}};
var choices=GalaxyStateFilterChoices.FromOriginal(filter,["sourceObservedState"] )!;
Check.That(choices.Select(c=>c.Key).ToHashSet().SetEquals(["none","unpopulated","savedstate","sourceobservedstate"]));
var values=GalaxyStateFilterChoices.Select(filter.Values,choices,"Unpopulated",true);
Check.That(values.SetEquals(["savedstate","unpopulated"])&&filter.Values!.SetEquals(["savedstate"]));
Check.That(GalaxyStateFilterChoices.FromOriginal(filter with{RequireOriginalStateFacts=false}) is null);
Check.That(GalaxyStateFilterChoices.FromOriginal(filter with{Category=GalaxyFilterCategory.Government}) is null);
Check.That(GalaxyStateFilterChoices.FromOriginal(Original()) is null);
}
}