Пример #1
0
        public void AddSpending_CategoryDoNotExists_NoChangesToSpendingListReturnFasle()
        {
            BudgetModel model = new BudgetModel();

            model.AddIncome(100);
            bool result = model.AddSpending("food", 50);

            Assert.IsFalse(result);
        }
Пример #2
0
        public void AddSpending_CategoryIsEmptyString_NoChangesToSpendingListReturnFasle()
        {
            BudgetModel model = new BudgetModel();

            model.AddIncome(100);
            model.AddCategory("food");
            bool result = model.AddSpending("", 10);

            Assert.IsFalse(result);
        }
Пример #3
0
        public void AddSpending_SpendingAmountIsNegativeNumberOrZero_NoChangesToSpendingListReturnFasle()
        {
            BudgetModel model = new BudgetModel();

            model.AddIncome(100);
            model.AddCategory("food");
            bool result = model.AddSpending("food", -10);

            Assert.IsFalse(result);
        }
Пример #4
0
        public void AddSpending_StandardInput_AddNewSpendingReturnTrue()
        {
            BudgetModel model = new BudgetModel();

            model.AddIncome(100);
            model.AddCategory("food");
            bool result = model.AddSpending("food", 50);

            Assert.IsTrue(result);
        }
Пример #5
0
        public void AddIncome_InputIsNegativeValue_NoChangesToBalanceAmount()
        {
            BudgetModel model    = new BudgetModel();
            decimal     expected = model.ShowBalanceAmount();
            decimal     value    = -10;

            model.AddIncome(value);
            decimal actual = model.ShowBalanceAmount();

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #6
0
        public void AddIncome_InputIsStandardValue_IncreaseBalanceAmountByValue()
        {
            BudgetModel model    = new BudgetModel();
            decimal     value    = 10;
            decimal     expected = model.ShowBalanceAmount() + value;

            model.AddIncome(value);
            decimal actual = model.ShowBalanceAmount();

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #7
0
        public void ShowSpendingsInCategoryByDay_CategoryIsNull_Return0()
        {
            BudgetModel model    = new BudgetModel();
            string      category = "food";

            model.AddCategory(category);
            model.AddIncome(20);
            model.AddSpending(category, 10);
            decimal expected = 0;

            decimal actual = model.ShowSpendingsInCategoryByDay(null, DateTime.Today);

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #8
0
        public void AddSpending_SpendingAmountIsNegativeNumber_NoChangesToBalance()
        {
            BudgetModel model = new BudgetModel();

            model.AddIncome(100);
            decimal expected = model.ShowBalanceAmount();

            model.AddCategory("food");
            bool result = model.AddSpending("food", -50);

            decimal actual = model.ShowBalanceAmount();

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #9
0
        public void AddSpending_StandardInput_DecBalanceByAmount()
        {
            BudgetModel model = new BudgetModel();

            model.AddIncome(100);
            decimal expected = model.ShowBalanceAmount() - 50;

            model.AddCategory("food");
            bool result = model.AddSpending("food", 50);

            decimal actual = model.ShowBalanceAmount();

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #10
0
        public void ShowSpendingsInCategoryByDay_TwoSpendingsWithAmounts10And15_Return25()
        {
            BudgetModel model    = new BudgetModel();
            string      category = "food";

            model.AddCategory(category);
            model.AddIncome(100);
            model.AddSpending(category, 10);
            model.AddSpending(category, 15);
            decimal expected = 25;

            decimal actual = model.ShowSpendingsInCategoryByDay("food", DateTime.Today);

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #11
0
        public void ShowAllSpendingsByInterval_TwoSpendingsWithAmounts5And12InOneCategory_Return17()
        {
            BudgetModel model    = new BudgetModel();
            string      category = "clothes";

            model.AddCategory(category);
            model.AddIncome(20);
            model.AddSpending(category, 5);
            model.AddSpending(category, 12);
            DateTime start    = new DateTime(2019, 2, 19);
            DateTime end      = DateTime.Today;
            decimal  expected = 17;

            decimal actual = model.ShowAllSpendingsByInterval(start, end);

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #12
0
        public void ShowSpendingsInCategoryByInterval_CategoryIsNull_Return0()
        {
            BudgetModel model    = new BudgetModel();
            string      category = "food";

            model.AddCategory(category);
            model.AddIncome(20);
            model.AddSpending(category, 5);
            model.AddSpending(category, 8);
            DateTime start    = new DateTime(2019, 2, 10);
            DateTime end      = new DateTime(2019, 2, 19);
            decimal  expected = 0;

            decimal actual = model.ShowSpendingsInCategoryByInterval(null, start, end);

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #13
0
        public void ShowSpendingsInCategoryByInterval_TwoSpendingsWithAmounts5And8_Return13()
        {
            BudgetModel model    = new BudgetModel();
            string      category = "food";

            model.AddCategory(category);
            model.AddIncome(20);
            model.AddSpending(category, 5);
            model.AddSpending(category, 8);
            DateTime start    = new DateTime(2019, 2, 18);
            DateTime end      = DateTime.Today;
            decimal  expected = 13;

            decimal actual = model.ShowSpendingsInCategoryByInterval(category, start, end);

            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #14
0
        public void ShowAllSpendingsByInterval_NoSpendingsInDateInterval_Return0()
        {
            BudgetModel model     = new BudgetModel();
            string      category1 = "clothes";
            string      category2 = "travelling";

            model.AddCategory(category1);
            model.AddCategory(category2);
            model.AddIncome(20);
            model.AddSpending(category1, 5);
            model.AddSpending(category2, 12);
            DateTime start    = new DateTime(2019, 2, 18);
            DateTime end      = new DateTime(2019, 2, 19);
            decimal  expected = 0;

            decimal actual = model.ShowAllSpendingsByInterval(start, end);

            Assert.That(actual, Is.EqualTo(expected));
        }