Files
h-school/tests/HSchool.Content.Tests/InheritanceTests.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

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