From 1eb828d53a055f628ad842786115dfff0215cf40 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 17 Oct 2026 20:03:27 +0200 Subject: [PATCH] PlaceNamesTests: a name another faction used is skipped, whatever its case Mutation triage: skipping used names, and comparing them case-sensitively, both survived because the table refuses repeats before a galaxy sees them. A list that did not come through the table (a package's factions) can still repeat one, so the draw rule's skip now has a test. Co-Authored-By: Claude Opus 5.5 --- .../Aetheria.Shared.Tests/PlaceNamesTests.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/PlaceNamesTests.cs b/tests/Aetheria.Shared.Tests/PlaceNamesTests.cs index b47d41c74..ffbd40e58 100644 --- a/tests/Aetheria.Shared.Tests/PlaceNamesTests.cs +++ b/tests/Aetheria.Shared.Tests/PlaceNamesTests.cs @@ -130,6 +130,33 @@ public sealed class PlaceNamesTests : IDisposable Assert.All(owned.Skip(2), zone => Assert.Matches(Designation, zone.Name)); } + // The table refuses a repeated name, but a list that did not come through it (a package's factions) can still hold + // one: the later faction skips a name the earlier one already used, whatever its case. + [Fact] + public void AnotherFactionsNameIsNotReusedWhateverItsCase() + { + var cache = RestoredHullsTests.OpenCatalog(); + _own.Add(cache); + var galaxy = Enumerable.Range(1, 20).Select(seed => { try { return Build(cache, true, (uint)seed); } catch (Exception) { return null; } }) + .First(g => g != null && Placed(g).Count(f => Owned(g, f).Length >= 2) >= 2); + var pair = Placed(galaxy).Where(f => Owned(galaxy, f).Length >= 2).Take(2).ToArray(); + var (first, later) = (pair[0], pair[1]); + Assert.True(Array.IndexOf(galaxy.Factions, first) < Array.IndexOf(galaxy.Factions, later)); + var taken = first.Places[0].Name; + var shouting = taken.ToUpperInvariant(); + Assert.NotEqual(taken, shouting); + var own = later.Places[0].Name; + later.Places = new[] { new FactionPlace { Name = shouting }, new FactionPlace { Name = own } }; + + var random = new Random(7); + galaxy.NamePlaces(ref random); + + Assert.Equal(taken, Owned(galaxy, first)[0].Name); + Assert.Equal(own, Owned(galaxy, later)[0].Name); + var names = galaxy.Zones.Select(z => z.Name).ToArray(); + Assert.Equal(names.Length, names.Distinct(StringComparer.OrdinalIgnoreCase).Count()); + } + [Fact] public void NoTwoZonesShareAName() {