private (Budget, BudgetPeriod) CreateNewUserRootBudget(User user) { BudgetDurationBase duration = new MonthlyBookEndedDuration(newUserRootBudgetDurationEndDate, newUserRootBudgetDurationShouldRollover); Fund rootFund = new Fund(newUserRootFundName, newUserRootFundBalance, duration, user.Id); DateTime startDate = DateTime.Now; DateTime endDate = duration.GetEndDateFromStartDate(startDate); BudgetPeriod firstBudgetPeriod = new BudgetPeriod(startDate, endDate); Budget firstRootBudget = new Budget(rootFund, firstBudgetPeriod); firstBudgetPeriod.RootBudget = firstRootBudget; return(firstRootBudget, firstBudgetPeriod); }
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); }
public void Test_CreateUser_SetsRootBudgetDurationToEndOn31st() { string firstName = "Ian"; string lastName = "Kirkpatrick"; string email = "*****@*****.**"; string username = "******"; int expectedDurationEndDay = 31; CreateUserCommand command = new CreateUserCommand(username, firstName, lastName, email); UserRootBudgetRelationship userRootBudgetRelationship = command.Run(); MonthlyBookEndedDuration duration = (MonthlyBookEndedDuration)userRootBudgetRelationship.RootBudget.Fund.Duration; Assert.Equal(duration.EndDayOfMonth, expectedDurationEndDay); }
public void Test_CreateUser_SetsRootBudgetDurationRolloverToFalse() { string firstName = "Ian"; string lastName = "Kirkpatrick"; string email = "*****@*****.**"; string username = "******"; bool expectedDurationRollover = false; CreateUserCommand command = new CreateUserCommand(username, firstName, lastName, email); UserRootBudgetRelationship userRootBudgetRelationship = command.Run(); MonthlyBookEndedDuration duration = (MonthlyBookEndedDuration)userRootBudgetRelationship.RootBudget.Fund.Duration; Assert.Equal(duration.RolloverEndDateOnSmallMonths, expectedDurationRollover); }