Beispiel #1
0
        public void ShouldAddMonthlyExpense()
        {
            dataProvider.AddExpenseItem(1, -10, "Gaz");

            var gaz = (from e in dataProvider.GetMonthlyCashStatementCategories() where e.Name == "Gaz" select e).Single();

            //

            Run();

            view.Expense.Date        = 01.02.of2009();
            view.Expense.Amount      = 20;
            view.Expense.Month       = 01.03.of2009();
            view.Expense.Description = "Found pocket";
            view.Expense.IsFinal     = true;;
            view.Expense.ExpenseItem = new PESelectableExpenseItem(gaz);
            view.OnOK();

            var expense = dataProvider.GetMonthlyCashMovements().Single();

            Assert.AreSame(gaz, expense.Category);
            AreEqual(01.02.of2009(), expense.Date);
            Assert.AreEqual(-20, expense.Amount);
            Assert.AreEqual(new YearMonth(3, 2009), expense.Month);
            Assert.AreEqual("Found pocket", expense.Description);
            Assert.AreEqual(true, expense.IsFinalPayment);

            showCalculationUseCaseMock.Verify(x => x.Run(), Times.Exactly(1));
        }
        public void AddExpense()
        {
            dataProvider.AddExpenseItem(1, 10, "Gaz");
            var gaz = dataProvider.GetMonthlyCashStatementCategories()[0];

            dataProvider.AddMonthlyCashStatement(gaz, month(1), 01.01.of2009(), 20, "tourne");

            persistentStorageMock.Verify(x => x.Set(dataContainer), Times.Exactly(2));
            CollectionAssert.AreEqual(
                new[] { new MonthlyCashStatement(gaz, month(1), 01.01.of2009(), 20, "tourne") },
                dataProvider.GetMonthlyCashMovements());
        }
        public void MonthlyExpensesAreCopied()
        {
            dataProvider.CalculationPeriod = 01.01.of2009() - 30.01.of2009();
            dataProvider.AddExpenseItem(1, 1, "Gaz");
            dataProvider.AddMonthlyCashStatement(dataProvider.GetMonthlyCashStatementCategories().Single(), new YearMonth(1, 2009), 05.01.of2009(), 5, "");
            //

            var preprocessor = CreatePreprocessor();

            CollectionAssert.AreEquivalent(
                dataProvider.GetMonthlyCashMovements(),
                preprocessor.MonthlyCashMovements.ToList());
        }