Enhance world simulation and API functionality; implement clock management improvements, ensure proper handling of world states during updates, and refine data persistence methods to prevent resurrecting deleted worlds.
This commit is contained in:
@@ -71,7 +71,31 @@ public sealed class GameTimeTests
|
||||
[Fact]
|
||||
public void ResolveStart_rejects_out_of_range_years()
|
||||
{
|
||||
// Year 10000 cannot even be constructed, so this has to sit just past the accepted range to
|
||||
// actually exercise ResolveStart.
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
GameTime.ResolveStart(new DateTime(10000, 1, 1)));
|
||||
GameTime.ResolveStart(new DateTime(9999, 1, 1, 0, 0, 0, DateTimeKind.Unspecified)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Advance_saturates_instead_of_running_off_the_end_of_the_calendar()
|
||||
{
|
||||
var nearTheEnd = new DateTime(9998, 12, 31, 23, 0, 0, DateTimeKind.Unspecified);
|
||||
|
||||
// A day of real time at x4 is roughly 16 game years - far past DateTime.MaxValue from here.
|
||||
var next = GameTime.Advance(nearTheEnd, TimeSpan.FromDays(1), timeScale: 4, paused: false);
|
||||
|
||||
Assert.Equal(DateTime.MaxValue, next);
|
||||
// Already saturated: the next tick must stay put rather than throw.
|
||||
Assert.Equal(DateTime.MaxValue, GameTime.Advance(next, TimeSpan.FromSeconds(1), 1, paused: false));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Advance_survives_an_absurd_wall_clock_gap()
|
||||
{
|
||||
// The naive product realElapsed.Ticks * 1200 overflows a long well before TimeSpan.MaxValue.
|
||||
var next = GameTime.Advance(GameTime.DefaultStart, TimeSpan.MaxValue, timeScale: 4, paused: false);
|
||||
|
||||
Assert.Equal(DateTime.MaxValue, next);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user