Inheritance: QuarterTimeRange
Beispiel #1
0
        public void CurrentQuarterTest()
        {
            var currentYear = ClockProxy.Clock.Now.Year;
            var quarter     = new QuarterRange(currentYear, QuarterKind.First);

            quarter.BaseYear.Should().Be(currentYear);
        }
        public void DefaultCalendarTest() {
            var yearStart = new DateTime(ClockProxy.Clock.Now.Year, 1, 1);

            Parallel.ForEach(Enum.GetValues(typeof(QuarterKind)).Cast<QuarterKind>(),
                             yearQuarter => {
                                 var offset = (int)yearQuarter - 1;
                                 var quarter = new QuarterRange(yearStart.AddMonths(TimeSpec.MonthsPerQuarter * offset));

                                 quarter.YearBaseMonth.Should().Be(1);
                                 quarter.BaseYear.Should().Be(yearStart.Year);
                                 quarter.Start.Should().Be(
                                     yearStart.AddMonths(TimeSpec.MonthsPerQuarter * offset).Add(quarter.TimeCalendar.StartOffset));
                                 quarter.End.Should().Be(
                                     yearStart.AddMonths(TimeSpec.MonthsPerQuarter * (offset + 1)).Add(quarter.TimeCalendar.EndOffset));
                             });
        }
Beispiel #3
0
        public void DefaultCalendarTest()
        {
            var yearStart = new DateTime(ClockProxy.Clock.Now.Year, 1, 1);

            Parallel.ForEach(Enum.GetValues(typeof(QuarterKind)).Cast <QuarterKind>(),
                             yearQuarter => {
                var offset  = (int)yearQuarter - 1;
                var quarter = new QuarterRange(yearStart.AddMonths(TimeSpec.MonthsPerQuarter * offset));

                quarter.YearBaseMonth.Should().Be(1);
                quarter.BaseYear.Should().Be(yearStart.Year);
                quarter.Start.Should().Be(
                    yearStart.AddMonths(TimeSpec.MonthsPerQuarter * offset).Add(quarter.TimeCalendar.StartOffset));
                quarter.End.Should().Be(
                    yearStart.AddMonths(TimeSpec.MonthsPerQuarter * (offset + 1)).Add(quarter.TimeCalendar.EndOffset));
            });
        }
Beispiel #4
0
        public void DefaultQuarterTest()
        {
            const int yearStartMonth = April;
            var       currentYear    = ClockProxy.Clock.Now.Year;

            var timeCalendar = TimeCalendar.New(TimeSpan.Zero, TimeSpan.Zero, yearStartMonth);

            var q1 = new QuarterRange(currentYear, QuarterKind.First, timeCalendar);

            q1.IsReadOnly.Should().Be.True();
            q1.YearBaseMonth.Should().Be(yearStartMonth);
            q1.Quarter.Should().Be(QuarterKind.First);
            q1.BaseYear.Should().Be(currentYear);
            q1.Start.Should().Be(new DateTime(currentYear, 4, 1));
            q1.End.Should().Be(new DateTime(currentYear, 7, 1));

            var q2 = new QuarterRange(currentYear, QuarterKind.Second, timeCalendar);

            q2.IsReadOnly.Should().Be.True();
            q2.YearBaseMonth.Should().Be(yearStartMonth);
            q2.Quarter.Should().Be(QuarterKind.Second);
            q2.BaseYear.Should().Be(currentYear);
            q2.Start.Should().Be(new DateTime(currentYear, 7, 1));
            q2.End.Should().Be(new DateTime(currentYear, 10, 1));

            var q3 = new QuarterRange(currentYear, QuarterKind.Third, timeCalendar);

            q3.IsReadOnly.Should().Be.True();
            q3.YearBaseMonth.Should().Be(yearStartMonth);
            q3.Quarter.Should().Be(QuarterKind.Third);
            q3.BaseYear.Should().Be(currentYear);
            q3.Start.Should().Be(new DateTime(currentYear, 10, 1));
            q3.End.Should().Be(new DateTime(currentYear + 1, 1, 1));

            var q4 = new QuarterRange(currentYear, QuarterKind.Fourth, timeCalendar);

            q4.IsReadOnly.Should().Be.True();
            q4.YearBaseMonth.Should().Be(yearStartMonth);
            q4.Quarter.Should().Be(QuarterKind.Fourth);
            q4.BaseYear.Should().Be(currentYear);
            q4.Start.Should().Be(new DateTime(currentYear + 1, 1, 1));
            q4.End.Should().Be(new DateTime(currentYear + 1, 4, 1));
        }
Beispiel #5
0
        public void GetMonthsTest()
        {
            var quarter = new QuarterRange(ClockProxy.Clock.Now.Year, QuarterKind.First, TimeCalendar.New(10));

            var months = quarter.GetMonths().ToTimePeriodCollection();

            months.Should().Not.Be.Null();
            months.Count.Should().Be.GreaterThan(0);

            int index = 0;

            foreach (MonthRange month in months)
            {
                month.Start.Should().Be(quarter.Start.AddMonths(index));
                month.UnmappedEnd.Should().Be(month.Start.AddMonths(1));

                index++;
            }

            Assert.AreEqual(TimeSpec.MonthsPerQuarter, index);
        }
Beispiel #6
0
        public void CalendarYearQuarterTest()
        {
            var currentYear  = ClockProxy.Clock.Now.Year;
            var timeCalendar = TimeCalendar.NewEmptyOffset();

            var current = new QuarterRange(currentYear, QuarterKind.First);

            current.GetNextQuarter().GetNextQuarter().GetNextQuarter().GetNextQuarter().Quarter.Should().Be(current.Quarter);
            current.GetPreviousQuarter().GetPreviousQuarter().GetPreviousQuarter().GetPreviousQuarter().Quarter.Should().Be(
                current.Quarter);

            var q1 = new QuarterRange(currentYear, QuarterKind.First, timeCalendar);

            Assert.IsTrue(q1.IsReadOnly);
            q1.Quarter.Should().Be(QuarterKind.First);
            q1.Start.Should().Be(new DateTime(currentYear, TimeSpec.FirstQuarterMonth, 1));
            q1.End.Should().Be(new DateTime(currentYear, TimeSpec.SecondQuarterMonth, 1));

            var q2 = new QuarterRange(currentYear, QuarterKind.Second, timeCalendar);

            Assert.IsTrue(q2.IsReadOnly);
            q2.Quarter.Should().Be(QuarterKind.Second);
            q2.Start.Should().Be(new DateTime(currentYear, TimeSpec.SecondQuarterMonth, 1));
            q2.End.Should().Be(new DateTime(currentYear, TimeSpec.ThirdQuarterMonth, 1));

            var q3 = new QuarterRange(currentYear, QuarterKind.Third, timeCalendar);

            Assert.IsTrue(q3.IsReadOnly);
            q3.Quarter.Should().Be(QuarterKind.Third);
            q3.Start.Should().Be(new DateTime(currentYear, TimeSpec.ThirdQuarterMonth, 1));
            q3.End.Should().Be(new DateTime(currentYear, TimeSpec.FourthQuarterMonth, 1));

            var q4 = new QuarterRange(currentYear, QuarterKind.Fourth, timeCalendar);

            Assert.IsTrue(q4.IsReadOnly);
            q4.Quarter.Should().Be(QuarterKind.Fourth);
            q4.Start.Should().Be(new DateTime(currentYear, TimeSpec.FourthQuarterMonth, 1));
            q4.End.Should().Be(new DateTime(currentYear + 1, TimeSpec.FirstQuarterMonth, 1));
        }
        public void InitValuesTest() {
            var now = ClockProxy.Clock.Now;
            var firstQuarter = now.TrimToMonth();
            var secondQuarter = firstQuarter.AddMonths(TimeSpec.MonthsPerQuarter);

            QuarterRange quarter = new QuarterRange(now.Year, QuarterKind.First, TimeCalendar.NewEmptyOffset());

            quarter.Start.Year.Should().Be(firstQuarter.Year);
            quarter.Start.Month.Should().Be(firstQuarter.Month);
            quarter.Start.Day.Should().Be(firstQuarter.Day);
            quarter.Start.Hour.Should().Be(0);
            quarter.Start.Minute.Should().Be(0);
            quarter.Start.Second.Should().Be(0);
            quarter.Start.Millisecond.Should().Be(0);

            quarter.End.Year.Should().Be(secondQuarter.Year);
            quarter.End.Month.Should().Be(secondQuarter.Month);
            quarter.End.Day.Should().Be(secondQuarter.Day);
            quarter.End.Hour.Should().Be(0);
            quarter.End.Minute.Should().Be(0);
            quarter.End.Second.Should().Be(0);
            quarter.End.Millisecond.Should().Be(0);
        }
Beispiel #8
0
        public void QuarterMomentTest()
        {
            var quarter = new QuarterRange(2008, QuarterKind.First, TimeCalendar.NewEmptyOffset());

            quarter.IsReadOnly.Should().Be.True();
            quarter.BaseYear.Should().Be(2008);
            quarter.Quarter.Should().Be(QuarterKind.First);
            quarter.Start.Should().Be(new DateTime(2008, TimeSpec.FirstQuarterMonth, 1));
            quarter.End.Should().Be(new DateTime(2008, TimeSpec.SecondQuarterMonth, 1));

            var previous = quarter.GetPreviousQuarter();

            previous.BaseYear.Should().Be(2007);
            previous.Quarter.Should().Be(QuarterKind.Fourth);
            previous.Start.Should().Be(new DateTime(2007, TimeSpec.FourthQuarterMonth, 1));
            previous.End.Should().Be(new DateTime(2008, TimeSpec.FirstQuarterMonth, 1));

            var next = quarter.GetNextQuarter();

            next.BaseYear.Should().Be(2008);
            next.Quarter.Should().Be(QuarterKind.Second);
            next.Start.Should().Be(new DateTime(2008, TimeSpec.SecondQuarterMonth, 1));
            next.End.Should().Be(new DateTime(2008, TimeSpec.ThirdQuarterMonth, 1));
        }
Beispiel #9
0
        public void InitValuesTest()
        {
            var now           = ClockProxy.Clock.Now;
            var firstQuarter  = now.TrimToMonth();
            var secondQuarter = firstQuarter.AddMonths(TimeSpec.MonthsPerQuarter);

            QuarterRange quarter = new QuarterRange(now.Year, QuarterKind.First, TimeCalendar.NewEmptyOffset());

            quarter.Start.Year.Should().Be(firstQuarter.Year);
            quarter.Start.Month.Should().Be(firstQuarter.Month);
            quarter.Start.Day.Should().Be(firstQuarter.Day);
            quarter.Start.Hour.Should().Be(0);
            quarter.Start.Minute.Should().Be(0);
            quarter.Start.Second.Should().Be(0);
            quarter.Start.Millisecond.Should().Be(0);

            quarter.End.Year.Should().Be(secondQuarter.Year);
            quarter.End.Month.Should().Be(secondQuarter.Month);
            quarter.End.Day.Should().Be(secondQuarter.Day);
            quarter.End.Hour.Should().Be(0);
            quarter.End.Minute.Should().Be(0);
            quarter.End.Second.Should().Be(0);
            quarter.End.Millisecond.Should().Be(0);
        }
Beispiel #10
0
        public void AddQuartersTest() {
            const int yearStartMonth = April;

            var currentYear = ClockProxy.Clock.Now.Year;
            var timeCalendar = TimeCalendar.New(TimeSpan.Zero, TimeSpan.Zero, yearStartMonth);

            var calendarStartDate = new DateTime(currentYear, 4, 1);
            var calendarQuarter = new QuarterRange(currentYear, QuarterKind.First, timeCalendar);

            Assert.AreEqual(calendarQuarter.AddQuarters(0), calendarQuarter);

            var prevQ1 = calendarQuarter.AddQuarters(-1);
            prevQ1.Quarter.Should().Be(QuarterKind.Fourth);
            prevQ1.BaseYear.Should().Be(currentYear - 1);
            prevQ1.Start.Should().Be(calendarStartDate.AddMonths(-3));
            prevQ1.End.Should().Be(calendarStartDate);

            var prevQ2 = calendarQuarter.AddQuarters(-2);
            prevQ2.Quarter.Should().Be(QuarterKind.Third);
            prevQ2.BaseYear.Should().Be(currentYear - 1);
            prevQ2.Start.Should().Be(calendarStartDate.AddMonths(-6));
            prevQ2.End.Should().Be(calendarStartDate.AddMonths(-3));

            var prevQ3 = calendarQuarter.AddQuarters(-3);
            prevQ3.Quarter.Should().Be(QuarterKind.Second);
            prevQ3.BaseYear.Should().Be(currentYear - 1);
            prevQ3.Start.Should().Be(calendarStartDate.AddMonths(-9));
            prevQ3.End.Should().Be(calendarStartDate.AddMonths(-6));

            var prevQ4 = calendarQuarter.AddQuarters(-4);
            prevQ4.Quarter.Should().Be(QuarterKind.First);
            prevQ4.BaseYear.Should().Be(currentYear - 1);
            prevQ4.Start.Should().Be(calendarStartDate.AddMonths(-12));
            prevQ4.End.Should().Be(calendarStartDate.AddMonths(-9));

            var prevQ5 = calendarQuarter.AddQuarters(-5);
            prevQ5.Quarter.Should().Be(QuarterKind.Fourth);
            prevQ5.BaseYear.Should().Be(currentYear - 2);
            prevQ5.Start.Should().Be(calendarStartDate.AddMonths(-15));
            prevQ5.End.Should().Be(calendarStartDate.AddMonths(-12));

            var futureQ1 = calendarQuarter.AddQuarters(1);
            futureQ1.Quarter.Should().Be(QuarterKind.Second);
            futureQ1.BaseYear.Should().Be(currentYear);
            futureQ1.Start.Should().Be(calendarStartDate.AddMonths(3));
            futureQ1.End.Should().Be(calendarStartDate.AddMonths(6));

            var futureQ2 = calendarQuarter.AddQuarters(2);
            futureQ2.Quarter.Should().Be(QuarterKind.Third);
            futureQ2.BaseYear.Should().Be(currentYear);
            futureQ2.Start.Should().Be(calendarStartDate.AddMonths(6));
            futureQ2.End.Should().Be(calendarStartDate.AddMonths(9));

            var futureQ3 = calendarQuarter.AddQuarters(3);
            futureQ3.Quarter.Should().Be(QuarterKind.Fourth);
            futureQ3.BaseYear.Should().Be(currentYear);
            futureQ3.Start.Should().Be(calendarStartDate.AddMonths(9));
            futureQ3.End.Should().Be(calendarStartDate.AddMonths(12));

            var futureQ4 = calendarQuarter.AddQuarters(4);
            futureQ4.Quarter.Should().Be(QuarterKind.First);
            futureQ4.BaseYear.Should().Be(currentYear + 1);
            futureQ4.Start.Should().Be(calendarStartDate.AddMonths(12));
            futureQ4.End.Should().Be(calendarStartDate.AddMonths(15));

            var futureQ5 = calendarQuarter.AddQuarters(5);
            futureQ5.Quarter.Should().Be(QuarterKind.Second);
            futureQ5.BaseYear.Should().Be(currentYear + 1);
            futureQ5.Start.Should().Be(calendarStartDate.AddMonths(15));
            futureQ5.End.Should().Be(calendarStartDate.AddMonths(18));
        }
Beispiel #11
0
        public void GetMonthsTest() {
            var quarter = new QuarterRange(ClockProxy.Clock.Now.Year, QuarterKind.First, TimeCalendar.New(10));

            var months = quarter.GetMonths().ToTimePeriodCollection();
            months.Should().Not.Be.Null();
            months.Count.Should().Be.GreaterThan(0);

            int index = 0;
            foreach(MonthRange month in months) {
                month.Start.Should().Be(quarter.Start.AddMonths(index));
                month.UnmappedEnd.Should().Be(month.Start.AddMonths(1));

                index++;
            }

            Assert.AreEqual(TimeSpec.MonthsPerQuarter, index);
        }
Beispiel #12
0
        public void DefaultQuarterTest() {
            const int yearStartMonth = April;
            var currentYear = ClockProxy.Clock.Now.Year;

            var timeCalendar = TimeCalendar.New(TimeSpan.Zero, TimeSpan.Zero, yearStartMonth);

            var q1 = new QuarterRange(currentYear, QuarterKind.First, timeCalendar);

            q1.IsReadOnly.Should().Be.True();
            q1.YearBaseMonth.Should().Be(yearStartMonth);
            q1.Quarter.Should().Be(QuarterKind.First);
            q1.BaseYear.Should().Be(currentYear);
            q1.Start.Should().Be(new DateTime(currentYear, 4, 1));
            q1.End.Should().Be(new DateTime(currentYear, 7, 1));

            var q2 = new QuarterRange(currentYear, QuarterKind.Second, timeCalendar);

            q2.IsReadOnly.Should().Be.True();
            q2.YearBaseMonth.Should().Be(yearStartMonth);
            q2.Quarter.Should().Be(QuarterKind.Second);
            q2.BaseYear.Should().Be(currentYear);
            q2.Start.Should().Be(new DateTime(currentYear, 7, 1));
            q2.End.Should().Be(new DateTime(currentYear, 10, 1));

            var q3 = new QuarterRange(currentYear, QuarterKind.Third, timeCalendar);

            q3.IsReadOnly.Should().Be.True();
            q3.YearBaseMonth.Should().Be(yearStartMonth);
            q3.Quarter.Should().Be(QuarterKind.Third);
            q3.BaseYear.Should().Be(currentYear);
            q3.Start.Should().Be(new DateTime(currentYear, 10, 1));
            q3.End.Should().Be(new DateTime(currentYear + 1, 1, 1));

            var q4 = new QuarterRange(currentYear, QuarterKind.Fourth, timeCalendar);

            q4.IsReadOnly.Should().Be.True();
            q4.YearBaseMonth.Should().Be(yearStartMonth);
            q4.Quarter.Should().Be(QuarterKind.Fourth);
            q4.BaseYear.Should().Be(currentYear);
            q4.Start.Should().Be(new DateTime(currentYear + 1, 1, 1));
            q4.End.Should().Be(new DateTime(currentYear + 1, 4, 1));
        }
Beispiel #13
0
        public void QuarterMomentTest() {
            var quarter = new QuarterRange(2008, QuarterKind.First, TimeCalendar.NewEmptyOffset());

            quarter.IsReadOnly.Should().Be.True();
            quarter.BaseYear.Should().Be(2008);
            quarter.Quarter.Should().Be(QuarterKind.First);
            quarter.Start.Should().Be(new DateTime(2008, TimeSpec.FirstQuarterMonth, 1));
            quarter.End.Should().Be(new DateTime(2008, TimeSpec.SecondQuarterMonth, 1));

            var previous = quarter.GetPreviousQuarter();

            previous.BaseYear.Should().Be(2007);
            previous.Quarter.Should().Be(QuarterKind.Fourth);
            previous.Start.Should().Be(new DateTime(2007, TimeSpec.FourthQuarterMonth, 1));
            previous.End.Should().Be(new DateTime(2008, TimeSpec.FirstQuarterMonth, 1));

            var next = quarter.GetNextQuarter();
            next.BaseYear.Should().Be(2008);
            next.Quarter.Should().Be(QuarterKind.Second);
            next.Start.Should().Be(new DateTime(2008, TimeSpec.SecondQuarterMonth, 1));
            next.End.Should().Be(new DateTime(2008, TimeSpec.ThirdQuarterMonth, 1));
        }
Beispiel #14
0
        public void CalendarYearQuarterTest() {
            var currentYear = ClockProxy.Clock.Now.Year;
            var timeCalendar = TimeCalendar.NewEmptyOffset();

            var current = new QuarterRange(currentYear, QuarterKind.First);
            current.GetNextQuarter().GetNextQuarter().GetNextQuarter().GetNextQuarter().Quarter.Should().Be(current.Quarter);
            current.GetPreviousQuarter().GetPreviousQuarter().GetPreviousQuarter().GetPreviousQuarter().Quarter.Should().Be(
                current.Quarter);

            var q1 = new QuarterRange(currentYear, QuarterKind.First, timeCalendar);

            Assert.IsTrue(q1.IsReadOnly);
            q1.Quarter.Should().Be(QuarterKind.First);
            q1.Start.Should().Be(new DateTime(currentYear, TimeSpec.FirstQuarterMonth, 1));
            q1.End.Should().Be(new DateTime(currentYear, TimeSpec.SecondQuarterMonth, 1));

            var q2 = new QuarterRange(currentYear, QuarterKind.Second, timeCalendar);

            Assert.IsTrue(q2.IsReadOnly);
            q2.Quarter.Should().Be(QuarterKind.Second);
            q2.Start.Should().Be(new DateTime(currentYear, TimeSpec.SecondQuarterMonth, 1));
            q2.End.Should().Be(new DateTime(currentYear, TimeSpec.ThirdQuarterMonth, 1));

            var q3 = new QuarterRange(currentYear, QuarterKind.Third, timeCalendar);

            Assert.IsTrue(q3.IsReadOnly);
            q3.Quarter.Should().Be(QuarterKind.Third);
            q3.Start.Should().Be(new DateTime(currentYear, TimeSpec.ThirdQuarterMonth, 1));
            q3.End.Should().Be(new DateTime(currentYear, TimeSpec.FourthQuarterMonth, 1));

            var q4 = new QuarterRange(currentYear, QuarterKind.Fourth, timeCalendar);

            Assert.IsTrue(q4.IsReadOnly);
            q4.Quarter.Should().Be(QuarterKind.Fourth);
            q4.Start.Should().Be(new DateTime(currentYear, TimeSpec.FourthQuarterMonth, 1));
            q4.End.Should().Be(new DateTime(currentYear + 1, TimeSpec.FirstQuarterMonth, 1));
        }
Beispiel #15
0
        public void AddQuartersTest()
        {
            const int yearStartMonth = April;

            var currentYear  = ClockProxy.Clock.Now.Year;
            var timeCalendar = TimeCalendar.New(TimeSpan.Zero, TimeSpan.Zero, yearStartMonth);

            var calendarStartDate = new DateTime(currentYear, 4, 1);
            var calendarQuarter   = new QuarterRange(currentYear, QuarterKind.First, timeCalendar);

            Assert.AreEqual(calendarQuarter.AddQuarters(0), calendarQuarter);

            var prevQ1 = calendarQuarter.AddQuarters(-1);

            prevQ1.Quarter.Should().Be(QuarterKind.Fourth);
            prevQ1.BaseYear.Should().Be(currentYear - 1);
            prevQ1.Start.Should().Be(calendarStartDate.AddMonths(-3));
            prevQ1.End.Should().Be(calendarStartDate);

            var prevQ2 = calendarQuarter.AddQuarters(-2);

            prevQ2.Quarter.Should().Be(QuarterKind.Third);
            prevQ2.BaseYear.Should().Be(currentYear - 1);
            prevQ2.Start.Should().Be(calendarStartDate.AddMonths(-6));
            prevQ2.End.Should().Be(calendarStartDate.AddMonths(-3));

            var prevQ3 = calendarQuarter.AddQuarters(-3);

            prevQ3.Quarter.Should().Be(QuarterKind.Second);
            prevQ3.BaseYear.Should().Be(currentYear - 1);
            prevQ3.Start.Should().Be(calendarStartDate.AddMonths(-9));
            prevQ3.End.Should().Be(calendarStartDate.AddMonths(-6));

            var prevQ4 = calendarQuarter.AddQuarters(-4);

            prevQ4.Quarter.Should().Be(QuarterKind.First);
            prevQ4.BaseYear.Should().Be(currentYear - 1);
            prevQ4.Start.Should().Be(calendarStartDate.AddMonths(-12));
            prevQ4.End.Should().Be(calendarStartDate.AddMonths(-9));

            var prevQ5 = calendarQuarter.AddQuarters(-5);

            prevQ5.Quarter.Should().Be(QuarterKind.Fourth);
            prevQ5.BaseYear.Should().Be(currentYear - 2);
            prevQ5.Start.Should().Be(calendarStartDate.AddMonths(-15));
            prevQ5.End.Should().Be(calendarStartDate.AddMonths(-12));

            var futureQ1 = calendarQuarter.AddQuarters(1);

            futureQ1.Quarter.Should().Be(QuarterKind.Second);
            futureQ1.BaseYear.Should().Be(currentYear);
            futureQ1.Start.Should().Be(calendarStartDate.AddMonths(3));
            futureQ1.End.Should().Be(calendarStartDate.AddMonths(6));

            var futureQ2 = calendarQuarter.AddQuarters(2);

            futureQ2.Quarter.Should().Be(QuarterKind.Third);
            futureQ2.BaseYear.Should().Be(currentYear);
            futureQ2.Start.Should().Be(calendarStartDate.AddMonths(6));
            futureQ2.End.Should().Be(calendarStartDate.AddMonths(9));

            var futureQ3 = calendarQuarter.AddQuarters(3);

            futureQ3.Quarter.Should().Be(QuarterKind.Fourth);
            futureQ3.BaseYear.Should().Be(currentYear);
            futureQ3.Start.Should().Be(calendarStartDate.AddMonths(9));
            futureQ3.End.Should().Be(calendarStartDate.AddMonths(12));

            var futureQ4 = calendarQuarter.AddQuarters(4);

            futureQ4.Quarter.Should().Be(QuarterKind.First);
            futureQ4.BaseYear.Should().Be(currentYear + 1);
            futureQ4.Start.Should().Be(calendarStartDate.AddMonths(12));
            futureQ4.End.Should().Be(calendarStartDate.AddMonths(15));

            var futureQ5 = calendarQuarter.AddQuarters(5);

            futureQ5.Quarter.Should().Be(QuarterKind.Second);
            futureQ5.BaseYear.Should().Be(currentYear + 1);
            futureQ5.Start.Should().Be(calendarStartDate.AddMonths(15));
            futureQ5.End.Should().Be(calendarStartDate.AddMonths(18));
        }
Beispiel #16
0
        public void CalendarQuarterOfYearTest() {
            var currentYear = ClockProxy.Clock.Now.Year;

            var timeCalendar = TimeCalendar.New(October);
            var calendarYear = new YearRange(currentYear, timeCalendar);

            calendarYear.YearBaseMonth.Should().Be(October);
            calendarYear.BaseYear.Should().Be(currentYear);
            calendarYear.Start.Should().Be(new DateTime(currentYear, October, 1));
            calendarYear.End.Should().Be(calendarYear.TimeCalendar.MapEnd(calendarYear.Start.AddYears(1)));
            calendarYear.UnmappedEnd.Should().Be(calendarYear.Start.AddYears(1));

            // Q1
            var q1 = new QuarterRange(calendarYear.BaseYear, QuarterKind.First, timeCalendar);
            q1.YearBaseMonth.Should().Be(calendarYear.YearBaseMonth);
            q1.BaseYear.Should().Be(calendarYear.BaseYear);
            q1.Start.Should().Be(new DateTime(currentYear, October, 1));
            q1.End.Should().Be(q1.TimeCalendar.MapEnd(q1.Start.AddMonths(TimeSpec.MonthsPerQuarter)));
            q1.UnmappedEnd.Should().Be(q1.Start.AddMonths(TimeSpec.MonthsPerQuarter));

            // Q2
            var q2 = new QuarterRange(calendarYear.BaseYear, QuarterKind.Second, timeCalendar);
            q2.YearBaseMonth.Should().Be(calendarYear.YearBaseMonth);
            q2.BaseYear.Should().Be(calendarYear.BaseYear);
            q2.Start.Should().Be(new DateTime(currentYear + 1, 1, 1));
            q2.End.Should().Be(q2.TimeCalendar.MapEnd(q2.Start.AddMonths(TimeSpec.MonthsPerQuarter)));
            q2.UnmappedEnd.Should().Be(q2.Start.AddMonths(TimeSpec.MonthsPerQuarter));

            // Q3
            var q3 = new QuarterRange(calendarYear.BaseYear, QuarterKind.Third, timeCalendar);
            q3.YearBaseMonth.Should().Be(calendarYear.YearBaseMonth);
            q3.BaseYear.Should().Be(calendarYear.BaseYear);
            q3.Start.Should().Be(new DateTime(currentYear + 1, 4, 1));
            q3.End.Should().Be(q3.TimeCalendar.MapEnd(q3.Start.AddMonths(TimeSpec.MonthsPerQuarter)));
            q3.UnmappedEnd.Should().Be(q3.Start.AddMonths(TimeSpec.MonthsPerQuarter));

            // Q4
            var q4 = new QuarterRange(calendarYear.BaseYear, QuarterKind.Fourth, timeCalendar);
            q4.YearBaseMonth.Should().Be(calendarYear.YearBaseMonth);
            q4.BaseYear.Should().Be(calendarYear.BaseYear);
            q4.Start.Should().Be(new DateTime(currentYear + 1, 7, 1));
            q4.End.Should().Be(q4.TimeCalendar.MapEnd(q4.Start.AddMonths(TimeSpec.MonthsPerQuarter)));
            q4.UnmappedEnd.Should().Be(q4.Start.AddMonths(TimeSpec.MonthsPerQuarter));
        }
Beispiel #17
0
 public void CurrentQuarterTest() {
     var currentYear = ClockProxy.Clock.Now.Year;
     var quarter = new QuarterRange(currentYear, QuarterKind.First);
     quarter.BaseYear.Should().Be(currentYear);
 }