using DeepDrftPublic.Client.Helpers; namespace DeepDrftTests; /// /// Unit tests for the home-stat-row runtime formatter (): /// the hh:mm shape, hour rollover past 60 minutes, multi-hour totals, and the clamp on non-positive / /// non-finite input. /// [TestFixture] public class RuntimeFormatTests { // 12h34m -> "12:34": the brief's worked example, hours not zero-padded, minutes two digits. [Test] public void ToHoursMinutes_TwelveHoursThirtyFour_FormatsHhMm() => Assert.That(RuntimeFormat.ToHoursMinutes((12 * 3600) + (34 * 60)), Is.EqualTo("12:34")); // 90 minutes rolls into 1 hour 30 minutes — minutes never exceed 59. [Test] public void ToHoursMinutes_NinetyMinutes_RollsIntoHours() => Assert.That(RuntimeFormat.ToHoursMinutes(90 * 60), Is.EqualTo("1:30")); // Sub-hour totals show 0 hours with zero-padded minutes. [Test] public void ToHoursMinutes_UnderOneHour_ShowsZeroHours() => Assert.That(RuntimeFormat.ToHoursMinutes(5 * 60), Is.EqualTo("0:05")); // Totals beyond 99h are not truncated — hours simply take more than two digits (mixes are few). [Test] public void ToHoursMinutes_BeyondNinetyNineHours_DoesNotTruncate() => Assert.That(RuntimeFormat.ToHoursMinutes((123 * 3600) + (45 * 60)), Is.EqualTo("123:45")); // Zero / negative / non-finite inputs clamp to "0:00" rather than producing a negative or NaN render. [TestCase(0d)] [TestCase(-10d)] [TestCase(double.NaN)] [TestCase(double.PositiveInfinity)] public void ToHoursMinutes_NonPositiveOrNonFinite_ClampsToZero(double seconds) => Assert.That(RuntimeFormat.ToHoursMinutes(seconds), Is.EqualTo("0:00")); }