Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }