Phase 40: clock tempo at 1 min/s, x5/x10 heavy stride.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AtX1_EveryImpulseRunsHeavySystems()
|
||||
{
|
||||
using var school = School.Create(1, "Каждый импульс", Start);
|
||||
school.Clock.SpeedIndex = 1;
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
school.Tick(OneTwentiethOfASecond, GameMinutesPerRealSecond);
|
||||
}
|
||||
|
||||
Assert.Equal(20, school.HeavySystemsInvocations);
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ public class GameClockTests
|
||||
private static readonly DateTime Start = new(2012, 4, 3, 6, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
private const double OneTwentiethOfASecond = 1d / 20d;
|
||||
private const double GameMinutesPerRealSecond = 5d;
|
||||
private const double GameMinutesPerRealSecond = 1d;
|
||||
|
||||
[Fact]
|
||||
public void NewClock_StartsRunningAtTheStartDate()
|
||||
@@ -32,7 +32,7 @@ public class GameClockTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OneRealSecond_AdvancesFiveGameMinutes()
|
||||
public void OneRealSecond_AdvancesOneGameMinute()
|
||||
{
|
||||
var clock = new GameClock(Start);
|
||||
|
||||
@@ -42,15 +42,28 @@ public class GameClockTests
|
||||
clock.Advance(OneTwentiethOfASecond, GameMinutesPerRealSecond);
|
||||
}
|
||||
|
||||
Assert.Equal(Start.AddMinutes(5), clock.Time);
|
||||
Assert.Equal(Start.AddMinutes(1), clock.Time);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TwentyStepsAtX1_AdvanceOneGameMinuteNotFive()
|
||||
{
|
||||
var clock = new GameClock(Start) { SpeedIndex = 1 };
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
clock.Advance(OneTwentiethOfASecond, GameMinutesPerRealSecond);
|
||||
}
|
||||
|
||||
Assert.Equal(Start.AddMinutes(1), clock.Time);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0, 2.5)]
|
||||
[InlineData(1, 5)]
|
||||
[InlineData(2, 10)]
|
||||
[InlineData(3, 15)]
|
||||
[InlineData(4, 20)]
|
||||
[InlineData(0, 0.5)]
|
||||
[InlineData(1, 1)]
|
||||
[InlineData(2, 2)]
|
||||
[InlineData(3, 5)]
|
||||
[InlineData(4, 10)]
|
||||
public void SpeedIndex_ScalesTheGameMinutesPerSecond(int speedIndex, double expectedMinutes)
|
||||
{
|
||||
var clock = new GameClock(Start) { SpeedIndex = speedIndex };
|
||||
|
||||
Reference in New Issue
Block a user