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.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using HSchool.Content;
|
||||
|
||||
namespace HSchool.Simulation.Tests;
|
||||
|
||||
public class SchoolTests
|
||||
@@ -39,4 +41,36 @@ public class SchoolTests
|
||||
|
||||
Assert.Equal(Start.AddMinutes(12), school.Clock.Time);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WithACatalogAndMap_KeepsThemOnTheSchool()
|
||||
{
|
||||
var loader = new CatalogLoader();
|
||||
var documents = new[]
|
||||
{
|
||||
new ContentDocument("core", "defs/actions/sit.jsonc", """{ "defName": "Sit" }"""),
|
||||
new ContentDocument("core", "defs/things/chair.jsonc", """{ "defName": "Chair", "actions": ["Sit"] }"""),
|
||||
new ContentDocument("core", "defs/territories/yard.jsonc", """{ "defName": "Yard" }"""),
|
||||
new ContentDocument("core", "defs/buildings/main.jsonc", """{ "defName": "Main" }"""),
|
||||
new ContentDocument("core", "defs/floors/floor.jsonc", """{ "defName": "Floor" }"""),
|
||||
new ContentDocument("core", "defs/rooms/office.jsonc", """{ "defName": "Office" }"""),
|
||||
};
|
||||
var catalog = loader.Load(["core"], documents);
|
||||
var map = new MapLayout
|
||||
{
|
||||
Territory = new TerritoryNode { Id = "yard", Def = "Yard" },
|
||||
Buildings = [new BuildingNode { Id = "main", Def = "Main" }],
|
||||
Floors = [new FloorNode { Id = "floor-1", Def = "Floor", Building = "main" }],
|
||||
Rooms = [new RoomNode { Id = "office", Def = "Office", Building = "main", Floor = "floor-1" }],
|
||||
Links = [new MapLink { A = "yard", B = "office" }],
|
||||
};
|
||||
MapValidator.Validate(map, catalog);
|
||||
|
||||
using var school = School.Create(1, "С картой", Start, catalog, map);
|
||||
school.Tick(1d / 20d, 5d);
|
||||
|
||||
Assert.Same(catalog, school.Catalog);
|
||||
Assert.Same(map, school.Map);
|
||||
Assert.True(school.Clock.Time > Start);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user