Files
Leonid Pershin 5490cfb247 Show a bare dash on ownerless school cards.
The design asked for the owner name or an em dash; wrapping the dash in the Owner template produced Хозяин: —. Low-speed clock tests now cover x1/2 and x2 as well as x1.
2026-08-20 16:06:59 +03:00

76 lines
2.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace HSchool.Simulation.Tests;
public class ClockTempoTests
{
private static readonly DateTime Start = new(2012, 4, 3, 6, 0, 0, DateTimeKind.Utc);
private const double OneTwentiethOfASecond = 1d / 20d;
private const double GameMinutesPerRealSecond = 1d;
[Fact]
public void AtX10_TwentyImpulses_RunHeavyTenTimesAndAdvanceTenGameMinutes()
{
using var school = School.Create(1, "Страйд", Start);
school.Clock.SpeedIndex = 4;
for (var i = 0; i < 20; i++)
{
school.Tick(OneTwentiethOfASecond, GameMinutesPerRealSecond);
}
Assert.Equal(Start.AddMinutes(10), school.Clock.Time);
Assert.Equal(10, school.HeavySystemsInvocations);
Assert.Equal(1d, school.LastHeavyGameMinutes);
}
[Theory]
[InlineData(0, 0.5)]
[InlineData(1, 1d)]
[InlineData(2, 2d)]
public void LowSpeed_EveryImpulseRunsHeavySystems(int speedIndex, double expectedMinutes)
{
using var school = School.Create(1, "Каждый импульс", Start);
school.Clock.SpeedIndex = speedIndex;
for (var i = 0; i < 20; i++)
{
school.Tick(OneTwentiethOfASecond, GameMinutesPerRealSecond);
}
Assert.Equal(Start.AddMinutes(expectedMinutes), school.Clock.Time);
Assert.Equal(20, school.HeavySystemsInvocations);
}
[Fact]
public void AtX5_TwentyImpulses_RunHeavyFiveTimesAndAdvanceFiveGameMinutes()
{
using var school = School.Create(1, "Страйд ×5", Start);
school.Clock.SpeedIndex = 3;
for (var i = 0; i < 20; i++)
{
school.Tick(OneTwentiethOfASecond, GameMinutesPerRealSecond);
}
Assert.Equal(Start.AddMinutes(5), school.Clock.Time);
Assert.Equal(5, school.HeavySystemsInvocations);
Assert.Equal(1d, school.LastHeavyGameMinutes);
}
[Theory]
[InlineData(3, 5d)]
[InlineData(4, 10d)]
public void HighSpeedIndex_OneRealSecond_AdvancesExpectedGameMinutes(int speedIndex, double expectedMinutes)
{
using var school = School.Create(1, "Быстро", Start);
school.Clock.SpeedIndex = speedIndex;
for (var i = 0; i < 20; i++)
{
school.Tick(OneTwentiethOfASecond, GameMinutesPerRealSecond);
}
Assert.Equal(Start.AddMinutes(expectedMinutes), school.Clock.Time);
}
}