Station package tests: every committed manifest is its shipped package; the Seized Refinery is an offered Pirate processing station
TheCommittedDepotManifestIsTheShippedDepot becomes a Theory over every directory under tools/blender/manifests and ties every field the packager writes (price, maker, name, description, offered, mass, durability, armor, drag besides rows and hull.scad). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c25491d8e7
commit
0e9e8ceaf5
2 changed files with 60 additions and 15 deletions
|
|
@ -18,22 +18,42 @@ public sealed class StationFacilityRoomTests
|
|||
Assert.Empty(StationKinds.FacilityRoomFaults(cache));
|
||||
}
|
||||
|
||||
// A repackage from the committed manifest reproduces the shipped depot: the manifest's kind, rows (Fa.1 included) and hull.scad are the
|
||||
// package's own. The packager is creation input only, so this keeps the two from drifting apart.
|
||||
[Fact]
|
||||
public void TheCommittedDepotManifestIsTheShippedDepot()
|
||||
// The committed manifests under tools/blender/manifests, one per station package (a new directory is checked without editing this test).
|
||||
public static TheoryData<string> Manifests()
|
||||
{
|
||||
var data = new TheoryData<string>();
|
||||
foreach (var directory in Directory.GetDirectories(Path.Combine(AetherDb.FindRoot(), "tools", "blender", "manifests")).OrderBy(d => d, System.StringComparer.Ordinal))
|
||||
data.Add(Path.GetFileName(directory));
|
||||
return data;
|
||||
}
|
||||
|
||||
// A repackage from a committed manifest reproduces its shipped package in every field the packager writes: hull.scad, name, kind, rows
|
||||
// (Fa.1 included), stats, price and the product's maker, name, description and whether it is offered. The packager is creation input
|
||||
// only, so this keeps the two from drifting apart.
|
||||
[Theory]
|
||||
[MemberData(nameof(Manifests))]
|
||||
public void TheCommittedManifestsAreTheShippedPackages(string directory)
|
||||
{
|
||||
var root = AetherDb.FindRoot();
|
||||
var manifest = JObject.Parse(File.ReadAllText(Path.Combine(root, "tools", "blender", "manifests", "arsenal-depot", "package.json")));
|
||||
Assert.Equal(File.ReadAllBytes(Path.Combine(root, "GameData", "Mods", "aetheria.arsenal-depot", "hull.scad")),
|
||||
File.ReadAllBytes(Path.Combine(root, "tools", "blender", "manifests", "arsenal-depot", "hull.scad")));
|
||||
var manifest = JObject.Parse(File.ReadAllText(Path.Combine(root, "tools", "blender", "manifests", directory, "package.json")));
|
||||
var id = (string) manifest["id"];
|
||||
Assert.Equal(File.ReadAllBytes(Path.Combine(root, "GameData", "Mods", id, "hull.scad")),
|
||||
File.ReadAllBytes(Path.Combine(root, "tools", "blender", "manifests", directory, "hull.scad")));
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var depot = Assert.Single(cache.GetAll<HullData>(), hull => hull.Name == (string) manifest["name"]);
|
||||
Assert.Equal("station-kind:" + (string) manifest["kind"], depot.Kind.Key.Value);
|
||||
var shipped = depot.Hardpoints.Select(row => $"{row.Transform}|{row.Type}|{row.Position.x},{row.Position.y}|{ShipAuthoringPush.Footprint(row.Shape)}|{(int) row.Rotation}|{row.Armor}|{row.FiringArc}").OrderBy(x => x);
|
||||
var key = ShipModCatalog.HullKey(id);
|
||||
var hull = Assert.Single(cache.GetAll<HullData>(), candidate => cache.RefOf(candidate).Key.Equals(key));
|
||||
Assert.Equal((string) manifest["name"], hull.Name);
|
||||
if (manifest["kind"] != null) Assert.Equal("station-kind:" + (string) manifest["kind"], hull.Kind.Key.Value);
|
||||
var shipped = hull.Hardpoints.Select(row => $"{row.Transform}|{row.Type}|{row.Position.x},{row.Position.y}|{ShipAuthoringPush.Footprint(row.Shape)}|{(int) row.Rotation}|{row.Armor}|{row.FiringArc}").OrderBy(x => x);
|
||||
var written = manifest["rows"].Select(row => $"{(string) row["id"]}|{(string) row["kind"]}|{(int) row["cell"][0]},{(int) row["cell"][1]}|{(string) row["footprint"]}|{(int) row["rotation"]}|{(float) row["armor"]}|{(float) row["arc"]}").OrderBy(x => x);
|
||||
Assert.Equal(shipped, written);
|
||||
Assert.Contains(depot.Hardpoints, row => row.Type == HardpointType.Facility);
|
||||
var stats = manifest["stats"];
|
||||
Assert.Equal(((float) stats["mass"], (float) stats["durability"], (float) stats["armor"], (float) stats["drag"]), (hull.Mass, hull.Durability, hull.Armor, hull.Drag));
|
||||
Assert.Equal((int) manifest["price"], hull.Price);
|
||||
var product = Assert.Single(cache.GetAll<FactionProductData>(), candidate => candidate.Design.Key.Equals(key));
|
||||
Assert.Equal(((string) manifest["maker"], (string) manifest["name"], (string) manifest["description"], !(bool) manifest["offered"]),
|
||||
(cache.Get(product.Manufacturer).Name, product.Name, product.Description, product.NotOffered));
|
||||
if (hull.HullType == HullType.Station) Assert.Contains(hull.Hardpoints, row => row.Type == HardpointType.Facility);
|
||||
}
|
||||
|
||||
// Positive control: Zenith's Facility rows taken away (in memory, on a read-only catalog), the census names the hull, a kind it
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@ using GameCult.Caching.MessagePack;
|
|||
using MessagePack;
|
||||
using Xunit;
|
||||
|
||||
// Station packages (aetheria-release, cut station-packages): a package hull of type Station enters the game as data through
|
||||
// the one compose path, names its kind (HullData.Kind, written by ship-authoring kind) and is drawn for that kind by
|
||||
// StationKinds and LoadoutGenerator. The first is GameData/Mods/aetheria.arsenal-depot, the Zhestokost Arsenal Depot, whose
|
||||
// offer makes every depot stand-in live. The tests read the owners (ruling census-tests-read-the-owners).
|
||||
// Station packages (aetheria-release, cuts station-packages and station-package-processing): a package hull of type Station enters
|
||||
// the game as data through the one compose path, names its kind (HullData.Kind, written by ship-authoring kind) and is drawn for that
|
||||
// kind by StationKinds and LoadoutGenerator. The first is GameData/Mods/aetheria.arsenal-depot, the Zhestokost Arsenal Depot, whose
|
||||
// offer makes every depot stand-in live; the second is aetheria.seized-refinery, the Pirates' Seized Refinery on a Zhestokost donor,
|
||||
// the processing station. The tests read the owners (ruling census-tests-read-the-owners).
|
||||
public sealed class StationPackageTests : IDisposable
|
||||
{
|
||||
private const string Id = "aetheria.arsenal-depot";
|
||||
private const string RefineryId = "aetheria.seized-refinery";
|
||||
private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-stationpackage-" + Guid.NewGuid().ToString("N"));
|
||||
private int _caches;
|
||||
|
||||
|
|
@ -66,6 +68,28 @@ public sealed class StationPackageTests : IDisposable
|
|||
Assert.True(LoadoutGenerator.IsDrawable(cache, product, hull));
|
||||
}
|
||||
|
||||
// The processing station: a Pirate-made, offered Station hull of kind processing whose Facility row takes the Refinery; Pirates, who
|
||||
// placed only mining before, can now field processing, and the Zhestokost stand-in to depot is unchanged.
|
||||
[Fact]
|
||||
public void TheSeizedRefineryIsAnOfferedPirateProcessingStation()
|
||||
{
|
||||
using var cache = Catalog();
|
||||
var hull = cache.Get(new CultRecordRef<HullData>(ShipModCatalog.HullKey(RefineryId)));
|
||||
Assert.NotNull(hull);
|
||||
Assert.Equal(("Seized Refinery", HullType.Station), (hull.Name, hull.HullType));
|
||||
Assert.Equal(StationKindData.KeyOf("processing"), hull.Kind.Key);
|
||||
Assert.True(hull.Visual.IsSet());
|
||||
var product = Assert.Single(cache.GetAll<FactionProductData>(), p => p.Design.Key.Equals(ShipModCatalog.HullKey(RefineryId)));
|
||||
var pirates = cache.Get(product.Manufacturer);
|
||||
Assert.Equal("Pirates", pirates.Name);
|
||||
Assert.True(LoadoutGenerator.IsDrawable(cache, product, hull));
|
||||
var refinery = Assert.Single(cache.GetAll<GearData>(), gear => gear.Name == "Refinery");
|
||||
Assert.Contains(hull.Hardpoints, row => row.Type == HardpointType.Facility && row.Takes(refinery));
|
||||
var processing = Kind("processing");
|
||||
Assert.Equal(processing.Key, StationKinds.HullKindFor(cache, pirates, processing).Key);
|
||||
Assert.Contains(processing.Key, StationKinds.FieldableKindsOf(cache, pirates).Select(fieldable => fieldable.Key));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EveryDepotStandInIsLive()
|
||||
{
|
||||
|
|
@ -88,6 +112,7 @@ public sealed class StationPackageTests : IDisposable
|
|||
using var cache = Catalog();
|
||||
var packages = cache.GetAll<HullData>().Where(hull => hull.HullType == HullType.Station && hull.Visual.IsSet()).ToArray();
|
||||
Assert.Contains(Depot(cache), packages);
|
||||
Assert.Contains(cache.Get(new CultRecordRef<HullData>(ShipModCatalog.HullKey(RefineryId))), packages);
|
||||
foreach (var hull in packages)
|
||||
{
|
||||
var makers = cache.GetAll<FactionProductData>().Where(p => p.Design.Key.Equals(cache.RefOf(hull).Key)).Select(p => cache.Get(p.Manufacturer));
|
||||
|
|
|
|||
Loading…
Reference in a new issue