Implement per-school save functionality by introducing a dedicated save directory and updating the school management system to support loading and saving school states. Revise documentation to reflect these changes, including updates to the architecture and design documents, and enhance the API for reloading schools from disk. Update tests to ensure proper functionality of the new save and reload features.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
namespace HSchool.Simulation.Tests;
|
||||
|
||||
public class SchoolTests
|
||||
{
|
||||
private static readonly DateTime Start = new(2012, 4, 3, 6, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
[Fact]
|
||||
public void Create_StartsRunningAtTheStartDate()
|
||||
{
|
||||
using var school = School.Create(1, "Гимназия", Start);
|
||||
|
||||
Assert.Equal(1, school.Id);
|
||||
Assert.Equal("Гимназия", school.Name);
|
||||
Assert.Equal(Start, school.Clock.Time);
|
||||
Assert.True(school.Clock.IsRunning);
|
||||
Assert.Equal(ClockSpeed.DefaultIndex, school.Clock.SpeedIndex);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_RestoresTimePauseAndSpeed()
|
||||
{
|
||||
var time = Start.AddHours(3);
|
||||
using var school = School.Load(7, "Сейв", time, running: false, speedIndex: 3);
|
||||
|
||||
Assert.Equal(7, school.Id);
|
||||
Assert.Equal("Сейв", school.Name);
|
||||
Assert.Equal(time, school.Clock.Time);
|
||||
Assert.False(school.Clock.IsRunning);
|
||||
Assert.Equal(3, school.Clock.SpeedIndex);
|
||||
Assert.Equal(DateTimeKind.Utc, school.Clock.Time.Kind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_PausedSchool_DoesNotMoveOnTick()
|
||||
{
|
||||
using var school = School.Load(1, "Пауза", Start.AddMinutes(12), running: false, speedIndex: 4);
|
||||
|
||||
school.Tick(1d / 20d, 5d);
|
||||
|
||||
Assert.Equal(Start.AddMinutes(12), school.Clock.Time);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user