Caching tests: a lost reference still refuses
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c53789f197
commit
126714c82a
1 changed files with 27 additions and 0 deletions
|
|
@ -36,6 +36,19 @@ namespace GameCult.Caching.Tests
|
|||
public CultRecordRef<RefListTarget>[] Items = Array.Empty<CultRecordRef<RefListTarget>>();
|
||||
}
|
||||
|
||||
// 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<string>();
|
||||
}
|
||||
|
||||
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<InvalidOperationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void A_Lost_Reference_Still_Refuses()
|
||||
{
|
||||
var registry = CultDocumentRegistry.Shared;
|
||||
var catalog = registry.GetRequired<RefListHolder>().ToCatalogEntry();
|
||||
catalog.SchemaId = "persisted.tests.reflist_holder.v1";
|
||||
catalog.ContentHash = "sha256:persisted-by-2.0";
|
||||
catalog.CompatibleSchemaIds = new[] { registry.GetRequired<RefListValueHolder>().SchemaId };
|
||||
catalog.Members.Single(member => member.Slot == 1).TypeName = "System.String[]";
|
||||
Assert.That(
|
||||
() => registry.ResolvePersistedSchemaReport(catalog.SchemaId, new[] { catalog }),
|
||||
Throws.TypeOf<InvalidOperationException>().With.Message.Contains("changed reference semantics"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void A_Gained_Reference_Does_Not_Excuse_A_Changed_Type_Or_Cardinality()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue