Example #1
0
        public void AddExpenseShouldIncreaseExpenseAfterItWasAlreadyAdded()
        {
            var list         = new ExpenseList();
            var expenseValue = new Money(10m);

            list.AddExpense(new Expense(Id, expenseValue));
            list.AddExpense(new Expense(Id, expenseValue));
            var updatedExpense = list.GetExpense(Id);

            Assert.AreEqual(new Money(20m), updatedExpense.Value);
        }
Example #2
0
        public void AddExpenseShouldIncreaseTotalWithTheExpense()
        {
            var list    = new ExpenseList();
            var expense = new Money(10m);

            list.AddExpense(new Expense(Id, expense));
            var totalExpense = list.TotalExpensesValue;

            Assert.AreEqual(expense, totalExpense);
        }
Example #3
0
        public void GetExpenseShouldReturnExpenseAfterItWasAddedWithAddExpenseUsingSameId()
        {
            var list         = new ExpenseList();
            var expenseValue = new Money(10m);

            list.AddExpense(new Expense(Id, expenseValue));
            var result = list.GetExpense(Id);

            Assert.AreEqual(expenseValue, result.Value);
        }
Example #4
0
        public ExpenseList CalculateExpenses(IEnumerable <Journey> journeys)
        {
            var expenseList = new ExpenseList();

            foreach (var journey in journeys)
            {
                var journeyExpense = _journeyCostPolicy.CalculateCost(journey);
                expenseList.AddExpense(journeyExpense);
            }
            return(expenseList);
        }