Ejemplo n.º 1
0
        //TestCaseSource'd test runs before SetUp() and SetUpFixture(), thus initialising in the static constructor
        static DateRangeHelperTests()
        {
            _fromIn = new DateTime(2000, 1, 5, 0, 0, 0);
            _toIn   = new DateTime(2000, 2, 2, 0, 0, 0);

            var firstDayOfWeek = new FirstDayOfWeekProvider().Value;

            _today             = DateTime.Now.Date;
            _yesterday         = _today.AddDays(-1);
            _daysBack30        = _today.AddDays(-29);
            _daysBack7         = _today.AddDays(-6);
            _weekFirstDay      = _today.GetWeekFirstDate(firstDayOfWeek).Date;
            _weekLastDay       = _weekFirstDay.AddDays(6);
            _lastWeekFirstDay  = _today.GetWeekFirstDate(firstDayOfWeek).Date.AddDays(-7);
            _lastWeekLastDay   = _today.GetWeekFirstDate(firstDayOfWeek).Date.AddDays(-1);
            _monthFirstDay     = _today.GetMonthFirstDate();
            _monthLastDay      = _today.GetMonthLastDate();
            _lastMonthFirstDay = _today.AddMonths(-1).GetMonthFirstDate();
            _lastMonthLastDay  = _today.AddMonths(-1).GetMonthLastDate();
            _yearFirstDay      = _today.GetYearFirstDate();
            _yearLastDay       = _today.GetYearLastDate();
            _yearBack          = _today.AddYears(-1).AddDays(1);
            _lastYearFirstDay  = _today.GetYearFirstDate().AddYears(-1);
            _lastYearLastDay   = _today.GetYearLastDate().AddYears(-1);
        }
Ejemplo n.º 2
0
        private static IDateRange GetDateRangeOfKind(DateRangeKind rangeKind, DayOfWeek firstDayOfWeek)
        {
            var firstDayOfWeekProvider = new FirstDayOfWeekProvider()
            {
                Value = firstDayOfWeek
            };
            var list = BuildDateRangeList(firstDayOfWeekProvider);

            list.CurrentKindOfRange = rangeKind;
            return(list.Current);
        }