public void GetNextMonthTest() { var month = new MonthRange(); month.GetNextMonth().Should().Be(month.AddMonths(1)); month.GetNextMonth().Start.Should().Be(ClockProxy.Clock.Now.AddMonths(1).StartTimeOfMonth()); }
public void AddMonthsTest() { var now = ClockProxy.Clock.Now; CultureTestData.Default .RunEach(culture => { var currentYearMonthStart = now.StartTimeOfMonth(); var currentYearMonthEnd = currentYearMonthStart.AddMonths(1); var currentYearMonth = new MonthRange(currentYearMonthStart, TimeCalendar.NewEmptyOffset(culture)); currentYearMonth.Start.Should().Be(currentYearMonthStart); currentYearMonth.End.Should().Be(currentYearMonthEnd); currentYearMonth.AddMonths(0).Should().Be(currentYearMonth); var previousYearMonthStart = new DateTime(now.Year - 1, now.Month, 1); var previousYearMonthEnd = previousYearMonthStart.AddMonths(1); var previousYearMonth = currentYearMonth.AddMonths(TimeSpec.MonthsPerYear * -1); previousYearMonth.Start.Should().Be(previousYearMonthStart); previousYearMonth.End.Should().Be(previousYearMonthEnd); previousYearMonth.Month.Should().Be(currentYearMonth.Month); previousYearMonth.Start.Year.Should().Be(currentYearMonth.Start.Year - 1); previousYearMonth.End.Year.Should().Be(currentYearMonth.End.Year - 1); var nextYearMonthStart = now.AddYears(1).StartTimeOfMonth(); var nextYearMonthEnd = nextYearMonthStart.AddMonths(1); var nextYearMonth = currentYearMonth.AddMonths(TimeSpec.MonthsPerYear); nextYearMonth.Start.Should().Be(nextYearMonthStart); nextYearMonth.End.Should().Be(nextYearMonthEnd); nextYearMonth.Month.Should().Be(currentYearMonth.Month); nextYearMonth.Start.Year.Should().Be(currentYearMonth.Start.Year + 1); nextYearMonth.End.Year.Should().Be(currentYearMonth.End.Year + 1); }); }
public void AddMonthsTest() { var now = ClockProxy.Clock.Now; CultureTestData.Default .RunEach(culture => { var currentYearMonthStart = now.StartTimeOfMonth(); var currentYearMonthEnd = currentYearMonthStart.AddMonths(1); var currentYearMonth = new MonthRange(currentYearMonthStart, TimeCalendar.NewEmptyOffset(culture)); currentYearMonth.Start.Should().Be(currentYearMonthStart); currentYearMonth.End.Should().Be(currentYearMonthEnd); currentYearMonth.AddMonths(0).Should().Be(currentYearMonth); var previousYearMonthStart = new DateTime(now.Year - 1, now.Month, 1); var previousYearMonthEnd = previousYearMonthStart.AddMonths(1); var previousYearMonth = currentYearMonth.AddMonths(TimeSpec.MonthsPerYear * -1); previousYearMonth.Start.Should().Be(previousYearMonthStart); previousYearMonth.End.Should().Be(previousYearMonthEnd); previousYearMonth.Month.Should().Be(currentYearMonth.Month); previousYearMonth.Start.Year.Should().Be(currentYearMonth.Start.Year - 1); previousYearMonth.End.Year.Should().Be(currentYearMonth.End.Year - 1); var nextYearMonthStart = now.AddYears(1).StartTimeOfMonth(); var nextYearMonthEnd = nextYearMonthStart.AddMonths(1); var nextYearMonth = currentYearMonth.AddMonths(TimeSpec.MonthsPerYear); nextYearMonth.Start.Should().Be(nextYearMonthStart); nextYearMonth.End.Should().Be(nextYearMonthEnd); nextYearMonth.Month.Should().Be(currentYearMonth.Month); nextYearMonth.Start.Year.Should().Be(currentYearMonth.Start.Year + 1); nextYearMonth.End.Year.Should().Be(currentYearMonth.End.Year + 1); }); }
public void GetNextMonthTest() { var month = new MonthRange(); month.GetNextMonth().Should().Be(month.AddMonths(1)); month.GetNextMonth().Start.Should().Be(ClockProxy.Clock.Now.AddMonths(1).StartTimeOfMonth()); }