public void AddHalfyearsTest() { const int yearStartMonth = April; var currentYear = ClockProxy.Clock.Now.Year; var timeCalendar = TimeCalendar.NewEmptyOffset(yearStartMonth); var calendarStartDate = new DateTime(currentYear, 4, 1); var calendarHalfyear = new HalfyearRange(currentYear, HalfyearKind.First, timeCalendar); calendarHalfyear.AddHalfyears(0).Should().Be(calendarHalfyear); var prevH1 = calendarHalfyear.AddHalfyears(-1); prevH1.Halfyear.Should().Be(HalfyearKind.Second); prevH1.BaseYear.Should().Be(currentYear - 1); prevH1.Start.Should().Be(calendarStartDate.AddMonths(-6)); prevH1.End.Should().Be(calendarStartDate); var prevH2 = calendarHalfyear.AddHalfyears(-2); prevH2.Halfyear.Should().Be(HalfyearKind.First); prevH2.BaseYear.Should().Be(currentYear - 1); prevH2.Start.Should().Be(calendarStartDate.AddMonths(-12)); prevH2.End.Should().Be(calendarStartDate.AddMonths(-6)); var prevH3 = calendarHalfyear.AddHalfyears(-3); prevH3.Halfyear.Should().Be(HalfyearKind.Second); prevH3.BaseYear.Should().Be(currentYear - 2); prevH3.Start.Should().Be(calendarStartDate.AddMonths(-18)); prevH3.End.Should().Be(calendarStartDate.AddMonths(-12)); var futureH1 = calendarHalfyear.AddHalfyears(1); futureH1.Halfyear.Should().Be(HalfyearKind.Second); futureH1.BaseYear.Should().Be(currentYear); futureH1.Start.Should().Be(calendarStartDate.AddMonths(6)); futureH1.End.Should().Be(calendarStartDate.AddMonths(12)); var futureH2 = calendarHalfyear.AddHalfyears(2); futureH2.Halfyear.Should().Be(HalfyearKind.First); futureH2.BaseYear.Should().Be(currentYear + 1); futureH2.Start.Should().Be(calendarStartDate.AddMonths(12)); futureH2.End.Should().Be(calendarStartDate.AddMonths(18)); var futureH3 = calendarHalfyear.AddHalfyears(3); futureH3.Halfyear.Should().Be(HalfyearKind.Second); futureH3.BaseYear.Should().Be(currentYear + 1); futureH3.Start.Should().Be(calendarStartDate.AddMonths(18)); futureH3.End.Should().Be(calendarStartDate.AddMonths(24)); }
public void AddHalfyearsTest() { const int yearStartMonth = April; var currentYear = ClockProxy.Clock.Now.Year; var timeCalendar = TimeCalendar.NewEmptyOffset(yearStartMonth); var calendarStartDate = new DateTime(currentYear, 4, 1); var calendarHalfyear = new HalfyearRange(currentYear, HalfyearKind.First, timeCalendar); calendarHalfyear.AddHalfyears(0).Should().Be(calendarHalfyear); var prevH1 = calendarHalfyear.AddHalfyears(-1); prevH1.Halfyear.Should().Be(HalfyearKind.Second); prevH1.BaseYear.Should().Be(currentYear - 1); prevH1.Start.Should().Be(calendarStartDate.AddMonths(-6)); prevH1.End.Should().Be(calendarStartDate); var prevH2 = calendarHalfyear.AddHalfyears(-2); prevH2.Halfyear.Should().Be(HalfyearKind.First); prevH2.BaseYear.Should().Be(currentYear - 1); prevH2.Start.Should().Be(calendarStartDate.AddMonths(-12)); prevH2.End.Should().Be(calendarStartDate.AddMonths(-6)); var prevH3 = calendarHalfyear.AddHalfyears(-3); prevH3.Halfyear.Should().Be(HalfyearKind.Second); prevH3.BaseYear.Should().Be(currentYear - 2); prevH3.Start.Should().Be(calendarStartDate.AddMonths(-18)); prevH3.End.Should().Be(calendarStartDate.AddMonths(-12)); var futureH1 = calendarHalfyear.AddHalfyears(1); futureH1.Halfyear.Should().Be(HalfyearKind.Second); futureH1.BaseYear.Should().Be(currentYear); futureH1.Start.Should().Be(calendarStartDate.AddMonths(6)); futureH1.End.Should().Be(calendarStartDate.AddMonths(12)); var futureH2 = calendarHalfyear.AddHalfyears(2); futureH2.Halfyear.Should().Be(HalfyearKind.First); futureH2.BaseYear.Should().Be(currentYear + 1); futureH2.Start.Should().Be(calendarStartDate.AddMonths(12)); futureH2.End.Should().Be(calendarStartDate.AddMonths(18)); var futureH3 = calendarHalfyear.AddHalfyears(3); futureH3.Halfyear.Should().Be(HalfyearKind.Second); futureH3.BaseYear.Should().Be(currentYear + 1); futureH3.Start.Should().Be(calendarStartDate.AddMonths(18)); futureH3.End.Should().Be(calendarStartDate.AddMonths(24)); }