protected void IntervalFormattedMustBeEqualInDaysToParsedIntervalCore() { TimeSpan expectedInterval = TimeSpan.FromDays(2.5F); string actualIntervalFormatted = TimeExtMethods.FormatInterval(expectedInterval, TimeExtMethods.FormatIntervalTimeUnit.Days); TimeSpan?actualInterval = TimeExtMethods.ParseInterval(actualIntervalFormatted); Assert.Equal(expectedInterval.TotalDays, actualInterval.Value.TotalDays); }
protected void IntervalFormattedMustBeEqualInHoursToParsedIntervalCore() { TimeSpan expectedInterval = 2.5.Hours(); string actualIntervalFormatted = TimeExtMethods.FormatInterval(expectedInterval, TimeExtMethods.FormatIntervalTimeUnit.Hours); TimeSpan?actualInterval = TimeExtMethods.ParseInterval(actualIntervalFormatted); Assert.Equal(expectedInterval.TotalHours, actualInterval.Value.TotalHours); }
protected void ClosestTimeUnitMustBeDaysCore() { TimeExtMethods.FormatIntervalTimeUnit expectedTimeUnit = TimeExtMethods.FormatIntervalTimeUnit.Days; TimeSpan interval = TimeSpan.FromDays(40); var closestTimeUnit = TimeExtMethods.DetectClosestTimeUnit(interval); Assert.True(closestTimeUnit == expectedTimeUnit); }
protected void IntervalParsedMustBeEqualInSecondsToFormattedIntervalCore() { TimeSpan expectedInterval = 2.5.Seconds(); string expectedIntervalFormatted = TimeExtMethods.FormatInterval(expectedInterval, TimeExtMethods.FormatIntervalTimeUnit.Seconds); TimeSpan?actualInterval = TimeExtMethods.ParseInterval(expectedIntervalFormatted); Assert.Equal(expectedInterval.TotalSeconds, actualInterval.Value.TotalSeconds); }
protected void ClosestTimeUnitMustBeHoursCore() { TimeExtMethods.FormatIntervalTimeUnit expectedTimeUnit = TimeExtMethods.FormatIntervalTimeUnit.Hours; TimeSpan interval = DateTime.Now.TimeOfDay; var closestTimeUnit = TimeExtMethods.DetectClosestTimeUnit(interval); Assert.True(closestTimeUnit == expectedTimeUnit); }