diff --git a/tests/GameCult.Thing.Contract.Tests/ParityTests.cs b/tests/GameCult.Thing.Contract.Tests/ParityTests.cs index 3cd5ce5..5aa8d95 100644 --- a/tests/GameCult.Thing.Contract.Tests/ParityTests.cs +++ b/tests/GameCult.Thing.Contract.Tests/ParityTests.cs @@ -36,6 +36,10 @@ public sealed class ParityTests (cache.GetAll().Single(), "asset-catalog", "thing:asset_catalog:provider.a.icons"), }; + // Stored under the package's own record key, the one keys.ts builds, so the other runtime finds each record by it. + private static void Put(CultCacheBatch batch, object document) => + batch.Upsert(document.GetType(), document, new CultRecordKey((string)document.GetType().GetProperty("RecordKey")!.GetValue(document)!)); + private static void AssertFiveRecords(CultCache cache) { foreach (var (value, golden, key) in Records(cache)) @@ -111,12 +115,14 @@ public sealed class ParityTests { using (var cache = CultCacheMessagePack.Create(scratch, new CultCacheOpenOptions { Registry = Wire.Registry })) { - cache.Commit(b => b - .Upsert(FullSurface()) - .Upsert(FullComposition()) - .Upsert(Invocation()) - .Upsert(Results(Invocation()).Single(r => r.Name == "result-pending").Result) - .Upsert(FullAssetCatalog())); + cache.Commit(b => + { + Put(b, FullSurface()); + Put(b, FullComposition()); + Put(b, Invocation()); + Put(b, Results(Invocation()).Single(r => r.Name == "result-pending").Result); + Put(b, FullAssetCatalog()); + }); cache.FlushAsync().GetAwaiter().GetResult(); } diff --git a/tests/thing-contract-parity/README.md b/tests/thing-contract-parity/README.md index 87895a0..ea5084b 100644 --- a/tests/thing-contract-parity/README.md +++ b/tests/thing-contract-parity/README.md @@ -6,5 +6,7 @@ The names the C# package `GameCult.Thing.Contract` gives its types. The C# packa |---|---| | `catalog-members.tsv` | One row per document slot, `schemaId`, `slot`, `memberName`, `typeName`, as `Wire.Registry`'s catalog entries print them. A list slot reads `System.Collections.Generic.IReadOnlyList`. | | `type-names.txt` | The full name of every public type in `GameCult.Thing.Contract`, sorted ordinally. | +| `written-by-cs.cc` | A single-file store the C# package's CultCache wrote from its own builders, one record of each kind. `packages/thing-contract/test/parity.test.ts` reads it. Regenerate: `THING_PARITY_WRITE=1 dotnet test tests/GameCult.Thing.Contract.Tests` (`ParityTests.cs`). | +| `written-by-ts.cc` | The same five records, written by `@gamecult/thing-contract`'s CultCache. `ParityTests.cs` reads it. Regenerate: `THING_PARITY_WRITE=1 npm test` in `packages/thing-contract` (`parity.test.ts`). | -`tests/GameCult.Thing.Contract.Tests/NameSetTests.cs` fails when either file disagrees with the C# types. These files change only in the commit that changes the C# types, and the other runtime packages read them without writing them. +`tests/GameCult.Thing.Contract.Tests/NameSetTests.cs` fails when either file disagrees with the C# types. The two name files change only in the commit that changes the C# types, and the other runtime packages read them without writing them. Each `.cc` is written by its own package and read by the other. diff --git a/tests/thing-contract-parity/written-by-cs.cc b/tests/thing-contract-parity/written-by-cs.cc new file mode 100644 index 0000000..ebd057f Binary files /dev/null and b/tests/thing-contract-parity/written-by-cs.cc differ