示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        protected void ClosestTimeUnitMustBeDaysCore()
        {
            TimeExtMethods.FormatIntervalTimeUnit expectedTimeUnit = TimeExtMethods.FormatIntervalTimeUnit.Days;
            TimeSpan interval        = TimeSpan.FromDays(40);
            var      closestTimeUnit = TimeExtMethods.DetectClosestTimeUnit(interval);

            Assert.True(closestTimeUnit == expectedTimeUnit);
        }
示例#4
0
        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);
        }
示例#5
0
        protected void ClosestTimeUnitMustBeHoursCore()
        {
            TimeExtMethods.FormatIntervalTimeUnit expectedTimeUnit = TimeExtMethods.FormatIntervalTimeUnit.Hours;
            TimeSpan interval        = DateTime.Now.TimeOfDay;
            var      closestTimeUnit = TimeExtMethods.DetectClosestTimeUnit(interval);

            Assert.True(closestTimeUnit == expectedTimeUnit);
        }