Example #1
0
        public void HalfyearTest()
        {
            DateTime now = ClockProxy.Clock.Now;

            DateTime halfyear = Now.Halfyear((YearMonth)now.Month);

            Assert.Equal(halfyear.Year, now.Year);
            Assert.Equal(halfyear.Month, now.Month);
            Assert.Equal(1, halfyear.Day);
            Assert.Equal(0, halfyear.Hour);
            Assert.Equal(0, halfyear.Minute);
            Assert.Equal(0, halfyear.Second);
            Assert.Equal(0, halfyear.Millisecond);

            int       testYear;
            YearMonth previousMonth;

            TimeTool.PreviousMonth((YearMonth)now.Month, out testYear, out previousMonth);
            DateTime previousHalfyear = Now.Halfyear(previousMonth);

            Assert.Equal(previousHalfyear.Year, now.AddMonths(-1).Year);
            Assert.Equal(previousHalfyear.Month, now.AddMonths(-1).Month);
            Assert.Equal(1, previousHalfyear.Day);
            Assert.Equal(0, previousHalfyear.Hour);
            Assert.Equal(0, previousHalfyear.Minute);
            Assert.Equal(0, previousHalfyear.Second);
            Assert.Equal(0, previousHalfyear.Millisecond);
        }         // HalfyearTest