using AcDream.Core.World; using Xunit; namespace AcDream.Core.Tests.World; public sealed class DerethDateTimeTests { [Fact] public void DayFraction_AtMidnight_IsZero() { Assert.Equal(0.0, DerethDateTime.DayFraction(0)); } [Fact] public void DayFraction_AtHalfDay_IsHalf() { Assert.Equal(0.5, DerethDateTime.DayFraction(DerethDateTime.DayTicks / 2), 4); } [Fact] public void DayFraction_WrapsAfterOneDay() { Assert.Equal(0.0, DerethDateTime.DayFraction(DerethDateTime.DayTicks), 6); Assert.Equal(0.25, DerethDateTime.DayFraction(DerethDateTime.DayTicks * 1.25), 4); } [Fact] public void CurrentHour_AtMidnight_IsDarktide() { Assert.Equal(DerethDateTime.HourName.Darktide, DerethDateTime.CurrentHour(0)); } [Fact] public void CurrentHour_AtDawn_IsDawnsong() { // Dawnsong is the 5th slot (0-indexed slot 4) — day-fraction 4/16 = 0.25. double ticks = DerethDateTime.DayTicks * (4.0 / 16.0); Assert.Equal(DerethDateTime.HourName.Dawnsong, DerethDateTime.CurrentHour(ticks)); } [Fact] public void CurrentHour_AtNoon_IsMidsong() { // Midsong is 0-indexed slot 8 → day-fraction 0.5. double ticks = DerethDateTime.DayTicks * 0.5; Assert.Equal(DerethDateTime.HourName.Midsong, DerethDateTime.CurrentHour(ticks)); } [Fact] public void IsDaytime_Dawn_True() { double ticks = DerethDateTime.DayTicks * (4.0 / 16.0); // Dawnsong start Assert.True(DerethDateTime.IsDaytime(ticks)); } [Fact] public void IsDaytime_Night_False() { double ticks = DerethDateTime.DayTicks * (1.0 / 16.0); // Darktide-and-Half Assert.False(DerethDateTime.IsDaytime(ticks)); } [Fact] public void ToCalendar_PY0Day1_Snowreap() { var cal = DerethDateTime.ToCalendar(0); Assert.Equal(0, cal.Year); Assert.Equal(DerethDateTime.MonthName.Snowreap, cal.Month); Assert.Equal(1, cal.Day); } [Fact] public void ToCalendar_AdvancesCorrectly() { // One year from start → PY 1, Snowreap 1. var cal = DerethDateTime.ToCalendar(DerethDateTime.YearTicks); Assert.Equal(1, cal.Year); Assert.Equal(DerethDateTime.MonthName.Snowreap, cal.Month); Assert.Equal(1, cal.Day); // One month into year 1. var cal2 = DerethDateTime.ToCalendar(DerethDateTime.YearTicks + DerethDateTime.MonthTicks); Assert.Equal(1, cal2.Year); Assert.Equal(DerethDateTime.MonthName.ColdMeet, cal2.Month); } }