Files
h-school/tests/HSchool.Content.Tests/PatchTests.cs
T
Leonid Pershin 4137400621
ci / server (push) Failing after 3m39s
ci / client (push) Successful in 14s
Enhance AI and simulation components with presence management and routing capabilities
- Introduced the `HSchool.Ai` project, responsible for routing, day plans, and presence management.
- Updated the `HSchool.Simulation` project to integrate with the new AI functionalities, improving decision-making and presence tracking.
- Added `travelMinutes` to room and territory definitions, ensuring accurate movement calculations within the simulation.
- Enhanced the `School` class to manage presence and implement empty-time skipping functionality.
- Updated documentation to reflect the new AI features and their impact on school simulation.
- Added tests for presence management and routing to ensure robust functionality and reliability.
2026-08-19 16:33:52 +03:00

99 lines
3.7 KiB
C#

namespace HSchool.Content.Tests;
public class PatchTests
{
private readonly CatalogLoader _loader = new();
[Fact]
public void Add_AppendsToActions()
{
var catalog = _loader.Load(
[CatalogLoader.CorePackId, "addon"],
[
PackDocuments.Def(CatalogLoader.CorePackId, "actions", "sit", """{ "defName": "Sit" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "actions", "inspect", """{ "defName": "Inspect" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "things", "chair", """{ "defName": "Chair", "actions": ["Sit"] }"""),
PackDocuments.Patch(
"addon",
"chair-inspect",
"""
{ "target": "Chair", "ops": [ { "op": "add", "path": "/actions/-", "value": "Inspect" } ] }
"""),
]);
Assert.Equal(["Sit", "Inspect"], catalog.Things["Chair"].Actions);
}
[Fact]
public void UnknownOp_FailsTheCatalog()
{
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load(
[CatalogLoader.CorePackId],
[
PackDocuments.Def(CatalogLoader.CorePackId, "things", "chair", """{ "defName": "Chair" }"""),
PackDocuments.Patch(
CatalogLoader.CorePackId,
"bad",
"""{ "target": "Chair", "ops": [ { "op": "move", "path": "/actions" } ] }"""),
]));
Assert.Contains("Unknown patch op", ex.Message);
}
[Fact]
public void MissingTarget_FailsTheCatalog()
{
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load(
[CatalogLoader.CorePackId],
[
PackDocuments.Def(CatalogLoader.CorePackId, "things", "chair", """{ "defName": "Chair" }"""),
PackDocuments.Patch(
CatalogLoader.CorePackId,
"ghost",
"""{ "target": "Missing", "ops": [ { "op": "remove", "path": "/actions" } ] }"""),
]));
Assert.Contains("was not found", ex.Message);
}
[Fact]
public void ReplaceAndRemove_EditRoomDef()
{
var catalog = _loader.Load(
[CatalogLoader.CorePackId, "addon"],
[
PackDocuments.Def(CatalogLoader.CorePackId, "things", "chair", """{ "defName": "Chair" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "things", "desk", """{ "defName": "Desk" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "works", "teach", """{ "defName": "TeachLesson" }"""),
PackDocuments.Def(CatalogLoader.CorePackId, "works", "walk", """{ "defName": "WalkSchool" }"""),
PackDocuments.Def(
CatalogLoader.CorePackId,
"rooms",
"office",
"""
{
"defName": "Office",
"slots": [ { "key": "seat", "thing": "Chair" } ],
"works": ["TeachLesson", "WalkSchool"],
"travelMinutes": 1
}
"""),
PackDocuments.Patch(
"addon",
"office",
"""
{
"target": "Office",
"ops": [
{ "op": "replace", "path": "/slots/0/thing", "value": "Desk" },
{ "op": "remove", "path": "/works/1" }
]
}
"""),
]);
Assert.Equal("Desk", catalog.Rooms["Office"].Slots[0].Thing);
Assert.Equal(["TeachLesson"], catalog.Rooms["Office"].Works);
}
}