예제 #1
0
        public void OnlyDates_Ok()
        {
            var startDate = new DateTime(2019, 06, 04);
            var endDate   = new DateTime(2019, 06, 05);

            var period = new NullableDateTimePeriod(startDate, endDate);

            Assert.Equal(startDate, period.Start);
            Assert.Equal(endDate, period.End);
        }
예제 #2
0
        public void OnlyDatesWithDayRange_Ok()
        {
            var startDate = new DateTime(2019, 06, 04);
            var endDate   = new DateTime(2019, 06, 05);

            var period = new NullableDateTimePeriod(startDate, endDate, dayRange: true);

            Assert.Equal(startDate, period.Start);
            Assert.Equal(endDate.Date.AddDays(1).Subtract(TimeSpan.FromMilliseconds(1)), period.End);
        }
예제 #3
0
        public void DatesWithSeparateTimeWithDayRange_Ok()
        {
            var startDate = new DateTime(2019, 06, 04);
            var startTime = new TimeSpan(11, 00, 00);
            var endDate   = new DateTime(2019, 06, 05);
            var endTime   = new TimeSpan(12, 00, 00);

            var period = new NullableDateTimePeriod(startDate, endDate, startTime, endTime, true);

            Assert.Equal(startDate.Add(startTime), period.Start);
            Assert.Equal(endDate.Date.AddDays(1).Subtract(TimeSpan.FromMilliseconds(1)), period.End);
        }
예제 #4
0
        public void DatesWithSeparateTime_TimeOfDateErased()
        {
            var startDate = new DateTime(2019, 06, 04, 10, 0, 0);
            var startTime = new TimeSpan(11, 00, 00);
            var endDate   = new DateTime(2019, 06, 05, 15, 0, 0);
            var endTime   = new TimeSpan(12, 00, 00);

            var period = new NullableDateTimePeriod(startDate, endDate, startTime, endTime);

            Assert.Equal(startDate.Date.Add(startTime), period.Start);
            Assert.Equal(endDate.Date.Add(endTime), period.End);
        }
예제 #5
0
        public void StartGreaterEnd_Throws()
        {
            var startDate = new DateTime(2019, 06, 04);
            var endDate   = new DateTime(2019, 06, 05);

            try
            {
                var period = new NullableDateTimePeriod(endDate, startDate);
                Assert.True(false);
            }
            catch
            {
                // ignored
            }
        }
예제 #6
0
        public void NoDateTimes_AllNull()
        {
            var period = new NullableDateTimePeriod(null, null, null, null, true);

            Assert.Equal(default, period.Start);