diff --git a/tests/GameCult.Caching.Tests/RefListDriftTests.cs b/tests/GameCult.Caching.Tests/RefListDriftTests.cs index 0582ac8e..77949bcb 100644 --- a/tests/GameCult.Caching.Tests/RefListDriftTests.cs +++ b/tests/GameCult.Caching.Tests/RefListDriftTests.cs @@ -36,6 +36,19 @@ namespace GameCult.Caching.Tests public CultRecordRef[] Items = Array.Empty>(); } + // The same slot declared as a plain value, as a later version might: the reverse of the 1.0.x drift. + [CultDocument("tests.reflist_holder", "tests.reflist_holder.v2")] + [MessagePackObject(AllowPrivate = true)] + internal sealed class RefListValueHolder + { + [Key(0)] + [CultName] + public string Name = string.Empty; + + [Key(1)] + public string[] Items = Array.Empty(); + } + private static string VectorPath(string name) { for (var dir = new DirectoryInfo(TestContext.CurrentContext.TestDirectory); dir != null; dir = dir.Parent) @@ -116,6 +129,20 @@ namespace GameCult.Caching.Tests Throws.TypeOf()); } + [Test] + public void A_Lost_Reference_Still_Refuses() + { + var registry = CultDocumentRegistry.Shared; + var catalog = registry.GetRequired().ToCatalogEntry(); + catalog.SchemaId = "persisted.tests.reflist_holder.v1"; + catalog.ContentHash = "sha256:persisted-by-2.0"; + catalog.CompatibleSchemaIds = new[] { registry.GetRequired().SchemaId }; + catalog.Members.Single(member => member.Slot == 1).TypeName = "System.String[]"; + Assert.That( + () => registry.ResolvePersistedSchemaReport(catalog.SchemaId, new[] { catalog }), + Throws.TypeOf().With.Message.Contains("changed reference semantics")); + } + [Test] public void A_Gained_Reference_Does_Not_Excuse_A_Changed_Type_Or_Cardinality() {