Files
Leonid Pershin b135a9caad Enhance protocol and simulation features with activity tracking and behavior definitions
- Updated protocol documentation to include new `activity` and `activityLabel` fields in the person card response, reflecting real-time activity status.
- Introduced `BehaviorDef` to define behavior rules, including need thresholds and lesson skill gains, enhancing AI decision-making.
- Revised the `DefCatalog` to incorporate behavior definitions and updated validation logic to ensure proper behavior handling.
- Enhanced the simulation to manage presence and activity states, allowing for more dynamic interactions within the school environment.
- Updated tests to validate the new activity tracking and behavior functionalities, ensuring robust performance and reliability.
- Improved localization strings to support new activity and behavior features, enhancing user experience.
2026-08-19 19:49:44 +03:00

58 lines
2.3 KiB
C#

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", "abstract": true }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "actions", "inspect", """{ "defName": "Inspect", "abstract": true }"""),
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", "travelMinutes": 1 }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "things", "chair", """{ "defName": "Chair", "parent": "Office" }"""),
]));
Assert.Contains("different kind", ex.Message, StringComparison.OrdinalIgnoreCase);
}
}