public void Expense_AddingNullExpenseDetail_ReturnInvalidExpense() { //Arrange var costCentre = "DEV002"; var total = 1024.01m; var paymentMethod = "personal card"; //Act var expense = new Expense(costCentre, total, paymentMethod); expense.CreateExpenseDetail(null); //Assert Assert.False(expense.IsValid()); }
private Expense GetValidExpense() { var costCentre = "DEV002"; var total = 1024.01m; var paymentMethod = "personal card"; var vendor = "Viaduct Steakhouse"; var description = "development team’s project end celebration dinner"; var date = new DateTime(2017, 4, 27); var expense = new Expense(costCentre, total, paymentMethod); var expenseDetail = new ExpenseDetail(vendor, description, date); expense.CreateExpenseDetail(expenseDetail); return(expense); }
internal static Expense ToExpense(ExpenseDTO expenseDTO) { if (expenseDTO == null || expenseDTO.Details == null) { return(null); } var expense = new Expense(expenseDTO.CostCentre, expenseDTO.Total, expenseDTO.PaymentMethod); var expenseDetail = new ExpenseDetail( expenseDTO.Details.Vendor, expenseDTO.Details.Description, expenseDTO.Details.Date); expense.CreateExpenseDetail(expenseDetail); return(expense); }
public void Expense_CreatingExpenseWithTotalLessThanZero_ReturnInvalidExpense() { //Arrange var costCentre = "DEV002"; var total = -0.01m; var paymentMethod = "personal card"; var vendor = "Viaduct Steakhouse"; var description = "development team’s project end celebration dinner"; var date = new DateTime(2017, 4, 27); //Act var expense = new Expense(costCentre, total, paymentMethod); var expenseDetail = new ExpenseDetail(vendor, description, date); expense.CreateExpenseDetail(expenseDetail); //Assert Assert.False(expense.IsValid()); }
public void Expense_CreatingExpenseMissingCostCentre_ReturnUnknownCostCentre() { //Arrange var total = 1024.01m; var paymentMethod = "personal card"; var vendor = "Viaduct Steakhouse"; var description = "development team’s project end celebration dinner"; var date = new DateTime(2017, 4, 27); //Act var expense = new Expense(string.Empty, total, paymentMethod); var expenseDetail = new ExpenseDetail(vendor, description, date); expense.CreateExpenseDetail(expenseDetail); //Assert Assert.True(expense.IsValid()); Assert.Equal("UNKNOWN", expense.CostCentre); }