Enhance school day structure and decision-making for lunch breaks
ci / server (push) Failing after 3m43s
ci / client (push) Successful in 15s

- Updated `ai.md` to clarify the mechanics of hunger restoration and the importance of lunch breaks in the school schedule.
- Revised `schedule.md` to detail the new lunch break structure, allowing for separate sittings for different grade levels.
- Enhanced `Decision.cs` and `DecisionPlanner.cs` to incorporate logic for lunch breaks, ensuring that students only leave lessons during their designated lunch windows.
- Updated `DayFrameDef` and related classes to support multiple lunch breaks and validate their configurations.
- Adjusted tests to validate the new decision-making logic regarding lunch breaks and hunger management, ensuring robust functionality.
- Improved localization strings to reflect changes in the school day structure and lunch functionalities.
This commit is contained in:
Leonid Pershin
2026-08-19 23:17:16 +03:00
parent a441ed9763
commit 5eabc90d53
33 changed files with 831 additions and 404 deletions
@@ -0,0 +1,81 @@
namespace HSchool.Simulation.Tests;
/// <summary>
/// What used to be checked through <c>SchoolRegistry</c>. The registry is gone — the server gives
/// every school its own worker — but the name and start-date rules it guarded are still the ones
/// the create endpoint applies.
/// </summary>
public class SchoolNamesTests
{
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
[InlineData("\u0009\u000A")]
public void BlankNames_AreRejected(string? name)
{
Assert.False(SchoolNames.TryNormalize(name, out _));
}
[Fact]
public void OverlongNames_AreRejected()
{
Assert.False(SchoolNames.TryNormalize(new string('ш', School.MaxNameLength + 1), out _));
Assert.True(SchoolNames.TryNormalize(new string('ш', School.MaxNameLength), out _));
}
[Fact]
public void SurroundingSpaceAndControlCharacters_AreStripped()
{
Assert.True(SchoolNames.TryNormalize(" Лицей ", out var normalized));
Assert.Equal("Лицей", normalized);
}
[Fact]
public void StartDatesOutsideTheSupportedRange_AreRejected()
{
Assert.False(GameClock.IsValidStartDate(new DateTime(1500, 1, 1, 0, 0, 0, DateTimeKind.Utc)));
Assert.False(GameClock.IsValidStartDate(new DateTime(3200, 1, 1, 0, 0, 0, DateTimeKind.Utc)));
Assert.True(GameClock.IsValidStartDate(new DateTime(2012, 4, 3, 6, 0, 0, DateTimeKind.Utc)));
}
[Fact]
public void SuggestedNames_AreUsableAndNeverRepeatATakenOne()
{
var generator = new SchoolNameGenerator(new Random(1234));
var taken = new List<string>();
for (var i = 0; i < 20; i++)
{
var suggestion = generator.Next(taken, SchoolNameLanguage.Russian);
Assert.True(SchoolNames.TryNormalize(suggestion, out _), $"\"{suggestion}\" is not a usable name.");
Assert.DoesNotContain(suggestion, taken, StringComparer.OrdinalIgnoreCase);
taken.Add(suggestion);
}
}
[Fact]
public void SuggestedNames_FitTheNameLimitInBothLanguages()
{
var generator = new SchoolNameGenerator(new Random(1234));
foreach (var language in new[] { SchoolNameLanguage.Russian, SchoolNameLanguage.English })
{
for (var i = 0; i < 200; i++)
{
Assert.InRange(generator.Next([], language).Length, 1, School.MaxNameLength);
}
}
}
[Fact]
public void SuggestedEnglishNames_AreAscii()
{
var generator = new SchoolNameGenerator(new Random(1234));
for (var i = 0; i < 50; i++)
{
Assert.Matches("^[A-Za-z0-9 .]+$", generator.Next([], SchoolNameLanguage.English));
}
}
}