Mesh tests: raw and typed writes share one readability vector test

The raw-write refusal test spelled the old header-only verdict (NotSupported for
a first slot that is a string, a legacy array replaced). The shared vector test
now drives both write paths; the old test keeps only the marked-file case.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 02:05:56 +02:00
commit e1ff5b2278
2 changed files with 24 additions and 45 deletions

View file

@ -56,20 +56,29 @@ public sealed class CultMeshSingleFileReadabilityTests
};
[TestCaseSource(nameof(Vectors))]
public void ATypedWriteReplacesAFileExactlyWhenItReads(string vector, bool reads)
public void AWriteReplacesAFileExactlyWhenItReads(string vector, bool reads)
{
var path = Path.Combine(_root, "doc.cc");
var bytes = File.ReadAllBytes(Path.Combine(VectorRoot(), vector));
File.WriteAllBytes(path, bytes);
if (reads)
var raw = new CultMeshSingleFileDocumentSchema("raw:schema", "RawSchema", "1");
var writes = new (string Name, Action<string> Write)[]
{
CultMesh.WriteSingleFileDocument(path, new CultRecordKey("publication"), Publication());
CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(path)).Records.Should().ContainSingle();
return;
}
("typed", path => CultMesh.WriteSingleFileDocument(path, new CultRecordKey("publication"), Publication())),
("raw payload", path => CultMesh.WriteSingleFileDocumentPayload(path, new CultRecordKey("publication"), raw, null, new byte[] { 0x90 }))
};
foreach (var (name, write) in writes)
{
var path = Path.Combine(_root, name.Replace(' ', '-') + ".cc");
var bytes = File.ReadAllBytes(Path.Combine(VectorRoot(), vector));
File.WriteAllBytes(path, bytes);
Assert.That(() => CultMesh.WriteSingleFileDocument(path, new CultRecordKey("publication"), Publication()), Throws.Exception);
File.ReadAllBytes(path).Should().Equal(bytes, "a file this runtime cannot read was rewritten");
if (reads)
{
write(path);
CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(path)).Records.Should().ContainSingle(name);
continue;
}
Assert.That(() => write(path), Throws.Exception, name);
File.ReadAllBytes(path).Should().Equal(bytes, name + " rewrote a file this runtime cannot read");
}
}
}