Beispiel #1
0
        public void Constructor3Minute()
        {
            var item = new TimeSpanItem(new DateTime(2000, 1, 1, 1, 1, 0), new DateTime(2000, 1, 1, 1, 2, 0), TimeSpanUnit.Minute);

            Assert.IsTrue(MathExtensions.AlmostEquals(item.AmountOf(TimeSpanUnit.Second), 60));
            Assert.IsTrue(MathExtensions.AlmostEquals(item.AmountOf(TimeSpanUnit.Minute), 1));
            Assert.AreEqual(item.Amount, 1);
        }
Beispiel #2
0
        public void Constructor2Default()
        {
            var item = new TimeSpanItem(new TimeSpan(0, 1, 0));

            Assert.IsTrue(MathExtensions.AlmostEquals(item.AmountOf(TimeSpanUnit.Second), 60));
            Assert.AreEqual(item.Amount, 60);
        }
Beispiel #3
0
        public void Constructor1Hour()
        {
            var item = new TimeSpanItem(12, TimeSpanUnit.Hour);

            Assert.AreEqual(item.Span, new TimeSpan(12, 0, 0));
            Assert.IsTrue(MathExtensions.AlmostEquals(item.AmountOf(TimeSpanUnit.Day), 0.5m));
        }
Beispiel #4
0
        public void Constructor1Minute()
        {
            var item = new TimeSpanItem(150, TimeSpanUnit.Minute);

            Assert.AreEqual(item.Span, new TimeSpan(2, 30, 0));
            Assert.IsTrue(MathExtensions.AlmostEquals(item.AmountOf(TimeSpanUnit.Hour), 2.5m));
        }
Beispiel #5
0
        public void RateCommon()
        {
            var _12min = new TimeSpanItem(new TimeSpan(0, 0, 12, 0), null, TimeSpanUnit.Minute, Rounding.AwayFromZero);

            Assert.IsTrue(MathExtensions.AlmostEquals(_12min.AmountOf(TimeSpanUnit.FiveMinutes), 2));

            var _12min30sec = new TimeSpanItem(new TimeSpan(0, 0, 12, 30), null, TimeSpanUnit.Minute, Rounding.AwayFromZero);

            Assert.IsTrue(MathExtensions.AlmostEquals(_12min30sec.AmountOf(TimeSpanUnit.FiveMinutes), 3));

            var _13min = new TimeSpanItem(new TimeSpan(0, 0, 13, 0), null, TimeSpanUnit.Minute, Rounding.AwayFromZero);

            Assert.IsTrue(MathExtensions.AlmostEquals(_13min.AmountOf(TimeSpanUnit.FiveMinutes), 3));
        }
Beispiel #6
0
        public void RateToEven()
        {
            var _12minToEven1 = new TimeSpanItem(new TimeSpan(0, 0, 12, 0), null, TimeSpanUnit.Minute, Rounding.HalfToEven);

            Assert.IsTrue(MathExtensions.AlmostEquals(_12minToEven1.AmountOf(TimeSpanUnit.FiveMinutes), 2));

            var _12minToEven2 = new TimeSpanItem(new TimeSpan(0, 0, 12, 30), null, TimeSpanUnit.Minute, Rounding.HalfToEven);

            Assert.IsTrue(MathExtensions.AlmostEquals(_12minToEven2.AmountOf(TimeSpanUnit.FiveMinutes), 2));

            var _12minToEven3 = new TimeSpanItem(new TimeSpan(0, 0, 13, 0), null, TimeSpanUnit.Minute, Rounding.HalfToEven);

            Assert.IsTrue(MathExtensions.AlmostEquals(_12minToEven3.AmountOf(TimeSpanUnit.FiveMinutes), 3));

            var _12minToEven4 = new TimeSpanItem(new TimeSpan(0, 0, 17, 30), null, TimeSpanUnit.Minute, Rounding.HalfToEven);

            Assert.IsTrue(MathExtensions.AlmostEquals(_12minToEven4.AmountOf(TimeSpanUnit.FiveMinutes), 4));
        }
Beispiel #7
0
        public void RateExactCommon()
        {
            var _10min = new TimeSpanItem(new TimeSpan(0, 0, 10, 0), null, TimeSpanUnit.Minute, Rounding.AwayFromZero);

            Assert.IsTrue(MathExtensions.AlmostEquals(_10min.AmountOf(TimeSpanUnit.FiveMinutes), 2));
        }
Beispiel #8
0
        public void RateNone()
        {
            var _12min = new TimeSpanItem(new TimeSpan(0, 0, 12, 0), null, TimeSpanUnit.Minute);

            Assert.IsTrue(MathExtensions.AlmostEquals(_12min.AmountOf(TimeSpanUnit.FiveMinutes), 2.4m));
        }