Tests (red at 42dce361): a CultLib 1.0.60 run.cc opens; Load names a ship file of a newer store format
tests/vectors/cultlib-1.0.60/run.cc is the run store Soul wrote with the base build (cl2-old-run-save-refused). Both new tests fail at the 2.0.0 pin; the first needs 2.0.1, the second needs ShipAuthoringStore.Load. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f448957f3a
commit
da5ba653cb
3 changed files with 52 additions and 0 deletions
33
tests/Aetheria.Shared.Tests/RunSaveCompatibilityTests.cs
Normal file
33
tests/Aetheria.Shared.Tests/RunSaveCompatibilityTests.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using Xunit;
|
||||
|
||||
// tests/vectors/cultlib-1.0.60/run.cc is a run.cc written by Aetheria on CultLib 1.0.60 (64 zones, factions, one entity).
|
||||
// A player's save outlives the runtime that wrote it, so the current runtime must open it as compatible drift.
|
||||
public sealed class RunSaveCompatibilityTests : IDisposable
|
||||
{
|
||||
private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-runcompat-" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
public RunSaveCompatibilityTests() => Directory.CreateDirectory(_root);
|
||||
|
||||
public void Dispose() => Directory.Delete(_root, true);
|
||||
|
||||
[Fact]
|
||||
public void ARunWrittenByCultLib1060OpensWithEveryZoneAndFactionResolving()
|
||||
{
|
||||
var run = Path.Combine(_root, "run.cc");
|
||||
File.Copy(Path.Combine(RunStartTests.FindRepoRoot(), "tests", "vectors", "cultlib-1.0.60", "run.cc"), run);
|
||||
using var cache = new CultCache(TestCatalog.Registry());
|
||||
cache.AddBackingStore(new SingleFileMessagePackBackingStore(TestCatalog.Repo, true), AetheriaStores.CatalogTypes);
|
||||
cache.AddBackingStore(new SingleFileMessagePackBackingStore(run), AetheriaStores.RunTypes);
|
||||
var saved = cache.GetGlobal<SavedGame>();
|
||||
Assert.NotNull(saved);
|
||||
Assert.NotEmpty(saved.Zones);
|
||||
Assert.NotEmpty(saved.Factions);
|
||||
Assert.All(saved.Zones, zone => Assert.NotNull(cache.Get(zone)));
|
||||
Assert.All(saved.Factions, faction => Assert.NotNull(cache.Get(faction)));
|
||||
}
|
||||
}
|
||||
|
|
@ -197,6 +197,25 @@ public sealed class ShipAuthoringTests
|
|||
Assert.IsType<NotSupportedException>(error.InnerException);
|
||||
}
|
||||
|
||||
// A store format this runtime does not know is refused on read with NotSupportedException from the attach; Load names the file.
|
||||
[Fact]
|
||||
public async Task LoadNamesTheFileWhoseStoreFormatIsNewer()
|
||||
{
|
||||
using var directory = new TempDirectory();
|
||||
var path = Path.Combine(directory.Path, "newer.cc");
|
||||
using (var cache = ShipAuthoringStore.Open(path, writable: true))
|
||||
{
|
||||
ShipAuthoringStore.Write(cache, Fixture().Hull, Fixture().Visual);
|
||||
await cache.FlushAsync();
|
||||
}
|
||||
var snapshot = CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(path));
|
||||
snapshot.FormatVersion = "cultcache.store.v9";
|
||||
File.WriteAllBytes(path, CultDocumentMessagePackSerialization.SerializeSnapshot(snapshot));
|
||||
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.
|
||||
private static void RewritePayload(string path, string schemaName, Action<object[]> edit)
|
||||
{
|
||||
|
|
|
|||
BIN
tests/vectors/cultlib-1.0.60/run.cc
Normal file
BIN
tests/vectors/cultlib-1.0.60/run.cc
Normal file
Binary file not shown.
Loading…
Reference in a new issue