コード例 #1
0
        public void TestMapInverseWithNullValue()
        {
            var map    = new DateTimeToSizeMap(DateTime.MinValue, DateTime.MaxValue, 0d, 1d, SortOrder.Ascending);
            var result = map.MapInverse(null);

            Assert.That(result, Is.Null);
        }
コード例 #2
0
        public void TestMapInverseReturnsNullWhenResultIsNotANumber()
        {
            var map    = new DateTimeToSizeMap(DateTime.MinValue, DateTime.MaxValue, 0d, 0d, SortOrder.Ascending);
            var result = map.MapInverse(0d);

            Assert.That(result, Is.Null);
        }
コード例 #3
0
        public void TestMapInverseWithOutOfRangeValues(double value, string expected)
        {
            var map          = new DateTimeToSizeMap(DateTime.MinValue, DateTime.MaxValue, 0d, 1d, SortOrder.Ascending);
            var expectedDate = DateTime.Parse(expected);
            var result       = map.MapInverse(value);

            Assert.That(result, Is.EqualTo(expectedDate).Within(TimeSpan.FromMilliseconds(1)));
        }
コード例 #4
0
        public void TestMapWithDescendingValues(string date, double expected)
        {
            var map    = new DateTimeToSizeMap(DateTime.MinValue, DateTime.MaxValue, 0d, 1d, SortOrder.Descending);
            var value  = DateTime.Parse(date);
            var result = map.Map(value);

            Assert.That(result, Is.EqualTo(expected).Within(0.0001));
        }
コード例 #5
0
        public void TestMapWithMillisecondValues(string time, double expected)
        {
            var min    = DateTime.Parse("1/1/0001 00:00:00.000");
            var max    = DateTime.Parse("1/1/0001 00:00:01.000");
            var map    = new DateTimeToSizeMap(min, max, 0d, 1d, SortOrder.Ascending);
            var value  = DateTime.Parse(time);
            var result = map.Map(value);

            Assert.That(result, Is.EqualTo(expected).Within(0.0001));
        }
コード例 #6
0
        public void TestMapInverseWithMillisecondValues(double value, string expected)
        {
            var min          = DateTime.Parse("1/1/0001 00:00:00.000");
            var max          = DateTime.Parse("1/1/0001 00:00:01.000");
            var map          = new DateTimeToSizeMap(min, max, 0d, 1d, SortOrder.Ascending);
            var expectedDate = DateTime.Parse(expected);
            var result       = map.MapInverse(value);

            Assert.That(result, Is.EqualTo(expectedDate));
        }