Aetheria/tests/Aetheria.Shared.Tests/AssemblyFromMakerCatalogTests.cs
Meta Vens c5905c3b7f Assembly is the maker's: lot quality drawn from Faction.AssemblyMean/Deviation, roles read min(part, assembly)
Deletes ItemManager.RollQuality and RarityTier.Rarity. Faction keys 19 and 20
(18 is reserved for Livery). AetherDb assembly-from-maker derives the fields.
Builds AetherDb on the CultLib 45c2f400 / CultMath 9c1b06cd pins; Shared.Tests
not yet run; the shipped-catalog test fails until the catalog commit follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 06:20:01 +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)));
}
}