Catalog subtraction: commodity records lose DemandProfile and both stored categories; the trade menu stops filtering by them
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5c38029ec0
commit
d3cd7813d7
4 changed files with 39 additions and 117 deletions
34
tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs
Normal file
34
tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using MessagePack;
|
||||
using Xunit;
|
||||
|
||||
// Commodity records carry no stored classification and no demand weights (aetheria-living-world, cut
|
||||
// catalog-subtraction): stage, component-ness and consumer-ness are derived later from recipes, roles and needs.
|
||||
public sealed class CommodityRecordsTests
|
||||
{
|
||||
// The shipped bytes still hold values at the retired keys; MessagePack skips them and every record loads by name.
|
||||
[Fact]
|
||||
public void ShippedCatalogOpensWithTheRetiredKeysGone()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
Assert.Equal(13, cache.GetAll<SimpleCommodityData>().Count());
|
||||
Assert.Equal(51, cache.GetAll<CompoundCommodityData>().Count());
|
||||
Assert.Contains(cache.GetAll<SimpleCommodityData>(), c => c.Name == "Ammo");
|
||||
Assert.All(cache.GetAll<CompoundCommodityData>(), c => Assert.False(string.IsNullOrEmpty(c.Name)));
|
||||
}
|
||||
|
||||
// Keys 10 and 11 are retired: no commodity member may reuse them for a different meaning.
|
||||
[Fact]
|
||||
public void RetiredKeysStayRetired()
|
||||
{
|
||||
int[] KeysOf(Type type) => type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
|
||||
.Select(f => f.GetCustomAttribute<KeyAttribute>()?.IntKey).Where(k => k.HasValue).Select(k => k.Value).ToArray();
|
||||
Assert.Equal(new[] { 9 }, KeysOf(typeof(SimpleCommodityData)));
|
||||
Assert.Empty(KeysOf(typeof(CompoundCommodityData)));
|
||||
Assert.Null(typeof(SimpleCommodityData).GetField("Category"));
|
||||
Assert.Null(typeof(CompoundCommodityData).GetField("Category"));
|
||||
Assert.Null(typeof(CompoundCommodityData).GetField("DemandProfile"));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue