ShipAuthoring: Load follows the pull's InvalidDataException, RefuseLegacyEmbeddedHull the nil-stamp NotSupportedException

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-10-22 20:23:32 +02:00
commit fb8f2ea2fb
2 changed files with 24 additions and 3 deletions

View file

@ -173,7 +173,28 @@ public sealed class ShipAuthoringTests
RewritePayload(path, "aetheria.hulldata", slots => ((object[])((object[])slots[5])[0])[2] = new object[] { 5, false, true, false });
var error = Assert.Throws<InvalidOperationException>(() => ShipAuthoringStore.Load(path));
Assert.Contains(path, error.Message);
Assert.IsAssignableFrom<MessagePackSerializationException>(error.InnerException);
// The pull names the record key and schema; the MessagePack failure is its cause.
var pull = Assert.IsType<InvalidDataException>(error.InnerException);
Assert.Contains("aetheria.hulldata", pull.Message);
Assert.Contains(ShipModCatalog.HullKey("mod.skiff").ToString(), pull.Message);
Assert.IsAssignableFrom<MessagePackSerializationException>(pull.InnerException);
}
// A store header with a nil format stamp is refused by the runtime with NotSupportedException; Load names the file.
[Fact]
public void LoadNamesTheFileWhoseFormatStampIsNil()
{
using var directory = new TempDirectory();
var path = Path.Combine(directory.Path, "nilstamp.cc");
File.WriteAllBytes(path, CultDocumentMessagePackSerialization.SerializeSnapshot(new CultPersistedStoreSnapshot
{
FormatVersion = null,
SchemaCatalog = Array.Empty<CultSchemaCatalogEntry>(),
Records = Array.Empty<CultPersistedRecord>(),
}));
var error = Assert.Throws<InvalidOperationException>(() => ShipAuthoringStore.Load(path));
Assert.Contains(path, error.Message);
Assert.IsType<NotSupportedException>(error.InnerException);
}
// Decodes one record's payload of the named schema to its slot array, lets the edit change it, and stores it again.