Aetheria/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs
Meta Vens d23038f53c Assembly is the maker's: re-land of h1 on 0f5def17 (net diff of ae300c6a..5187a59d)
Applies the net diff of eureka/aetheria-release-assembly-from-maker (5187a59d) without its catalog blob and RunStartTests residue, git apply -3, overlaps resolved on master's side. 066fb581's message ('git log --oneline -1') was a heredoc slip; the old branch stays as it is. Drops the Rarity = fixture member from the tests master added since ae300c6a. Faction keys 19-20 here are h1's; the next commit reshapes them to one Assembly at 19.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:55:16 +02:00

35 lines
1.4 KiB
C#

using System;
using System.Linq;
using System.Reflection;
using MessagePack;
using Xunit;
// The shipped catalog carries each maker's derived assembly, and the Faction format pins its wire positions
// (aetheria-release, cut assembly-from-maker).
public sealed class AssemblyFromMakerCatalogTests
{
[Fact]
public void ShippedCatalogCarriesDerivation()
{
using var cache = RestoredHullsTests.OpenCatalog();
var products = cache.GetAll<FactionProductData>().Where(p => p.Roles.Count > 0).ToArray();
var makers = products.Select(p => p.Manufacturer.Key).Distinct().ToArray();
Assert.NotEmpty(makers);
foreach (var key in makers)
{
var roles = products.Where(p => p.Manufacturer.Key.Equals(key)).SelectMany(p => p.Roles).ToArray();
var faction = cache.Get<Faction>(key);
Assert.Equal(Math.Round(roles.Average(r => r.Mean), 2), faction.AssemblyMean, 2);
Assert.Equal(Math.Round(roles.Average(r => r.StandardDeviation), 2), faction.AssemblyDeviation, 2);
}
}
// 16 is reserved for Relations, 17 is Doctrine, 18 is reserved for Livery.
[Fact]
public void AssemblyFieldsSitAtKeys19And20()
{
int KeyOf(string field) => typeof(Faction).GetField(field).GetCustomAttribute<KeyAttribute>().IntKey.Value;
Assert.Equal(19, KeyOf(nameof(Faction.AssemblyMean)));
Assert.Equal(20, KeyOf(nameof(Faction.AssemblyDeviation)));
}
}