示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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());
        }
示例#5
0
        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);
        }