Example #1
0
        public void test_complete_date_range_5()
        {
            var start = new TruncatedDate(null, 12, 22);
            var end   = new TruncatedDate(null, 12, 27);

            var trdRange = new TruncatedDateRange(start, end);
            var comp     = trdRange.ToCompleteDateRanges(2016, 2018);

            //should be 3 ranges, one for each year
            Assert.NotNull(comp);
            Assert.AreEqual(3, comp.Length);

            Assert.AreEqual(12, comp[0].DateStart.Month);
            Assert.AreEqual(22, comp[0].DateStart.Day);

            Assert.AreEqual(12, comp[2].DateEnd.Month);
            Assert.AreEqual(27, comp[2].DateEnd.Day);

            Assert.AreEqual(2016, comp[0].DateStart.Year);
            Assert.AreEqual(2017, comp[1].DateStart.Year);
            Assert.AreEqual(2018, comp[2].DateStart.Year);

            Assert.AreEqual(2016, comp[0].DateEnd.Year);
            Assert.AreEqual(2017, comp[1].DateEnd.Year);
            Assert.AreEqual(2018, comp[2].DateEnd.Year);
        }
Example #2
0
        public void test_complete_date_range_4()
        {
            var start = new TruncatedDate(2014, null, null);
            var end   = new TruncatedDate(2015, null, null);

            var trdRange = new TruncatedDateRange(start, end);
            var comp     = trdRange.ToCompleteDateRanges(2016, 2018);

            //Not within given period of interest
            Assert.Null(comp);
        }
Example #3
0
        public void test_within_truncated_range_2()
        {
            //each year 2017-07-22 .. 08-12
            var start = new TruncatedDate(2017, 7, null);
            var end   = new TruncatedDate(2017, 8, null);

            var trdRange = new TruncatedDateRange(start, end);

            Assert.False(trdRange.IsWithin(new CompleteDate(2016, 7, 22)));
            Assert.True(trdRange.IsWithin(new CompleteDate(2017, 7, 1)));
            Assert.True(trdRange.IsWithin(new CompleteDate(2017, 8, 12)));
        }
Example #4
0
        public void test_within_truncated_range_3()
        {
            var start = new TruncatedDate(2017, null, 12);
            var end   = new TruncatedDate(2017, null, 15);

            var trdRange = new TruncatedDateRange(start, end);

            Assert.False(trdRange.IsWithin(new CompleteDate(2017, 7, 16)));
            Assert.False(trdRange.IsWithin(new CompleteDate(2016, 7, 13)));
            Assert.True(trdRange.IsWithin(new CompleteDate(2017, 7, 15)));
            Assert.True(trdRange.IsWithin(new CompleteDate(2017, 1, 12)));
        }
Example #5
0
        public void test_complete_date_range_3()
        {
            var start = new TruncatedDate(2014, null, null);
            var end   = new TruncatedDate(2017, null, null);

            var trdRange = new TruncatedDateRange(start, end);
            var comp     = trdRange.ToCompleteDateRanges(2016, 2018);

            Assert.AreEqual(1, comp.Length);
            Assert.NotNull(comp);

            Assert.AreEqual("20140101", comp[0].DateStart.BasicFormat);
            Assert.AreEqual("20171231", comp[0].DateEnd.BasicFormat);
        }
Example #6
0
        public void test_within_truncated_range_1()
        {
            //each year 07-22 .. 08-12
            var start = new TruncatedDate(null, 7, 22);
            var end   = new TruncatedDate(null, 8, 12);

            var trdRange = new TruncatedDateRange(start, end);

            Assert.True(trdRange.IsWithin(new CompleteDate(1730, 7, 22)));
            Assert.True(trdRange.IsWithin(new CompleteDate(1730, 7, 31)));
            Assert.True(trdRange.IsWithin(new CompleteDate(1730, 8, 12)));

            Assert.False(trdRange.IsWithin(new CompleteDate(1730, 7, 21)));
            Assert.False(trdRange.IsWithin(new CompleteDate(2017, 7, 21)));
        }