Beispiel #1
0
        public void FiscalYearsLastDayGetHalfyearsTest()
        {
            const int             yearCount = 13;
            Years                 years     = new Years(2006, yearCount, GetFiscalYearCalendar(FiscalYearAlignment.LastDay));
            ITimePeriodCollection halfyears = years.GetHalfyears();

            Assert.NotNull(halfyears);
            Assert.Equal(halfyears.Count, yearCount * TimeSpec.HalfyearsPerYear);

            Assert.Equal(halfyears[0].Start, new DateTime(2006, 8, 27));
            foreach (Halfyear halfyear in halfyears)
            {
                // last halfyear of a leap year
                // http://en.wikipedia.org/wiki/4-4-5_Calendar
                if ((halfyear.YearHalfyear == YearHalfyear.Second) && (halfyear.Year == 2008 || halfyear.Year == 2013 || halfyear.Year == 2019))
                {
                    if (halfyear.Duration.Subtract(TimeCalendar.DefaultEndOffset).Days != TimeSpec.FiscalDaysPerLeapHalfyear)
                    {
                        Console.WriteLine();
                    }

                    Assert.Equal(halfyear.Duration.Subtract(TimeCalendar.DefaultEndOffset).Days, TimeSpec.FiscalDaysPerLeapHalfyear);
                }
                else
                {
                    Assert.Equal(halfyear.Duration.Subtract(TimeCalendar.DefaultEndOffset).Days, TimeSpec.FiscalDaysPerHalfyear);
                }
            }
        }         // FiscalYearsLastDayGetHalfyearsTest
Beispiel #2
0
        public void GetHalfyearsTest()
        {
            const int       startYear  = 2004;
            const int       yearCount  = 10;
            const YearMonth startMonth = YearMonth.October;
            Years           years      = new Years(startYear, yearCount, TimeCalendar.New(startMonth));

            ITimePeriodCollection halfyears = years.GetHalfyears();

            Assert.NotNull(halfyears);

            int index = 0;

            foreach (Halfyear halfyear in halfyears)
            {
                int halfyearYear = startYear + (index / TimeSpec.HalfyearsPerYear);
                Assert.Equal(halfyear.Year, halfyearYear);
                Assert.Equal(halfyear.Start, years.Start.AddMonths(index * TimeSpec.MonthsPerHalfyear));
                Assert.Equal(halfyear.End, halfyear.Calendar.MapEnd(halfyear.Start.AddMonths(TimeSpec.MonthsPerHalfyear)));
                index++;
            }
            Assert.Equal(index, yearCount * TimeSpec.HalfyearsPerYear);
        }         // GetHalfyearsTest