Add HSchool.Content project for JSONC definitions, catalog, and map validation. Update solution structure to include new content and tests projects. Enhance school management to support mod packs and map instances, ensuring proper loading and validation. Revise documentation to reflect these changes and update tests for new functionality.
ci / server (push) Failing after 3m36s
ci / client (push) Successful in 13s

This commit is contained in:
Leonid Pershin
2026-08-18 14:35:09 +03:00
parent 37c39a3beb
commit 1bc75244e8
55 changed files with 2289 additions and 59 deletions
@@ -0,0 +1,57 @@
namespace HSchool.Content.Tests;
public class InheritanceTests
{
private readonly CatalogLoader _loader = new();
[Fact]
public void ChildField_ReplacesParentArrayWholesale()
{
var catalog = _loader.Load(
[CatalogLoader.CorePackId],
[
PackDocuments.Def(CatalogLoader.CorePackId, "actions", "sit", """{ "defName": "Sit" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "actions", "inspect", """{ "defName": "Inspect" }"""),
PackDocuments.Def(
CatalogLoader.CorePackId,
"things",
"base",
"""{ "defName": "FurnitureBase", "abstract": true, "actions": ["Sit", "Inspect"] }"""),
PackDocuments.Def(
CatalogLoader.CorePackId,
"things",
"chair",
"""{ "defName": "Chair", "parent": "FurnitureBase", "actions": ["Sit"] }"""),
]);
Assert.Equal(["Sit"], catalog.Things["Chair"].Actions);
Assert.False(catalog.Things["Chair"].Abstract);
Assert.True(catalog.Things["FurnitureBase"].Abstract);
}
[Fact]
public void CyclicParent_FailsTheCatalog()
{
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load(
[CatalogLoader.CorePackId],
[
PackDocuments.Def(CatalogLoader.CorePackId, "things", "a", """{ "defName": "A", "parent": "B" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "things", "b", """{ "defName": "B", "parent": "A" }"""),
]));
Assert.Contains("cyclic", ex.Message, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void ParentOfAnotherKind_FailsTheCatalog()
{
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load(
[CatalogLoader.CorePackId],
[
PackDocuments.Def(CatalogLoader.CorePackId, "rooms", "office", """{ "defName": "Office" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "things", "chair", """{ "defName": "Chair", "parent": "Office" }"""),
]));
Assert.Contains("different kind", ex.Message, StringComparison.OrdinalIgnoreCase);
}
}