private void InitRandomDuration(bool?isDaySpanDuration = null) { isDaySpanDuration = isDaySpanDuration ?? _faker.Random.Bool(); if (isDaySpanDuration == true) { _durationBuilder = _budgetDurationBuilderProvider.GetBuilder <DaySpanDuration>(); } else { _durationBuilder = _budgetDurationBuilderProvider.GetBuilder <MonthlyBookEndedDuration>(); } }
public void Test_DaySpanDurationGetEndDate_ReturnsCorrect(int startYear, int startMonth, int startDay, int numberDays, int expectedYear, int expectedMonth, int expectedDay) { BudgetDurationBuilderProvider builderProvider = _builderFactoryFixture.GetService <BudgetDurationBuilderProvider>(); DaySpanDuration subject = (DaySpanDuration)((DaySpanDurationBuilder)builderProvider.GetBuilder <DaySpanDuration>()) .SetNumberDays(numberDays) .Build(); DateTime startDate = new DateTime(startYear, startMonth, startDay); DateTime expected = new DateTime(expectedYear, expectedMonth, expectedDay); DateTime actual = subject.GetEndDateFromStartDate(startDate); Assert.Equal(expected, actual); }
public void Test_BookendedDurationGetEndDate_ReturnsCorrect(int startYear, int startMonth, int startDay, int endDate, bool rolover, int expectedYear, int expectedMonth, int expectedDay) { BudgetDurationBuilderProvider builderProvider = _builderFactoryFixture.GetService <BudgetDurationBuilderProvider>(); MonthlyBookEndedDuration subject = (MonthlyBookEndedDuration)((MonthlyBookEndedDurationBuilder)builderProvider.GetBuilder <MonthlyBookEndedDuration>()) .SetDurationEndDayOfMonth(endDate) .SetDurationRolloverEndDateOnSmallMonths(rolover) .Build(); DateTime startDate = new DateTime(startYear, startMonth, startDay); DateTime expected = new DateTime(expectedYear, expectedMonth, expectedDay); DateTime actual = subject.GetEndDateFromStartDate(startDate); Assert.Equal(expected, actual); }