Example #1
0
        public void GetStartDateOfYearShouldReturnTheCorrectEndDateForTheLastDay()
        {
            var date = new DateTime(2016, 12, 31, 0, 0, 0);

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de");
            var endDate = new DateCalculationService().GetStartDateOfYear(date);

            endDate.ToString("dd.MM.yyyy HH:mm:ss").Should()
            .Be(new DateTime(2016, 01, 01, 0, 0, 0).ToString("dd.MM.yyyy HH:mm:ss"));
        }
Example #2
0
        public void GetEndDateOfMonthShouldReturnTheCorrectEndDate()
        {
            var date = new DateTime(2016, 08, 23, 0, 0, 0);

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de");
            var endDate = new DateCalculationService().GetEndDateOfMonth(date);

            endDate.ToString("dd.MM.yyyy HH:mm:ss").Should()
            .Be(new DateTime(2016, 08, 31, 23, 59, 59).ToString("dd.MM.yyyy HH:mm:ss"));
        }
Example #3
0
        public void GetStartAndEndDateOfMonthShouldReturnTheCorrectStartAndEndDateForTheLastDay()
        {
            var date = new DateTime(2016, 08, 1, 0, 0, 0);

            DateTime endDate;

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de");
            var startDate = new DateCalculationService().GetStartAndEndDateOfMonth(date, out endDate);

            endDate.ToString("dd.MM.yyyy HH:mm:ss").Should()
            .Be(new DateTime(2016, 08, 31, 23, 59, 59).ToString("dd.MM.yyyy HH:mm:ss"));
            startDate.ToString("dd.MM.yyyy HH:mm:ss").Should()
            .Be(new DateTime(2016, 08, 1, 0, 0, 0).ToString("dd.MM.yyyy HH:mm:ss"));
        }
Example #4
0
        public void GetStartAndEndDateOfQuarterShouldReturnTheCorrectQuarterForTheFirstDay()
        {
            var date = new DateTime(2016, 08, 31, 0, 0, 0);

            DateTime endDate;
            int      quarter;

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de");
            var startDate = new DateCalculationService().GetStartAndEndDateOfQuarter(date, out endDate, out quarter);

            endDate.ToString("dd.MM.yyyy HH:mm:ss").Should()
            .Be(new DateTime(2016, 09, 30, 23, 59, 59).ToString("dd.MM.yyyy HH:mm:ss"));
            startDate.ToString("dd.MM.yyyy HH:mm:ss").Should()
            .Be(new DateTime(2016, 07, 1, 0, 0, 0).ToString("dd.MM.yyyy HH:mm:ss"));
            quarter.Should().Be(3);
        }