Exemple #1
0
        public void CanSupportAnnualBudgetEntries()
        {
            var anualEntry = new BudgetEntryAnnual(900.00, 1, "Mariners", BudgetType.Entertainment_SportingEvents);

            _budget.AddEntry(anualEntry);
            Assert.That(_budget.TotalExpenses, Is.EqualTo(900.00));
            Assert.That(_budget.MonthlyExpenses(1), Is.EqualTo(900.00));
            Assert.That(_budget.MonthlyExpenses(2), Is.EqualTo(0.0));
        }
Exemple #2
0
        public static BudgetEntry CreateBudgetEntry(params string[] components)
        {
            BudgetEntry result = null;

            double     amount;
            string     label;
            BudgetType budgetType;
            int        month;
            string     dayStart;
            int        weekPeriod;
            int        weekMax;

            string type;

            GetNextValueAndAdvance(ref components, out type);
            GetCommonParameters(ref components, out amount, out label, out budgetType);
            switch (type)
            {
            case "Annual":
                GetNextValueAndAdvance(ref components, out month);
                result = new BudgetEntryAnnual(amount, month, label, budgetType);
                break;

            case "BiAnnual":
                GetNextValueAndAdvance(ref components, out month);
                result = new BudgetEntryBiAnnual(amount, month, label, budgetType);
                break;

            case "Monthly":
                result = new BudgetEntryMonthly(amount, label, budgetType);
                break;

            case "BiMonthly":
                GetNextValueAndAdvance(ref components, out month);
                result = new BudgetEntryBiMonthly(amount, month, label, budgetType);
                break;

            case "Weekly":
                GetNextValueAndAdvance(ref components, out dayStart);
                GetNextValueAndAdvance(ref components, out weekPeriod);
                GetNextValueAndAdvance(ref components, out weekMax);
                result = new BudgetEntryWeekly(amount, label, budgetType, weekPeriod, dayStart, weekMax);
                break;

            case "Daily":
                GetNextValueAndAdvance(ref components, out dayStart);
                result = new BudgetEntryDaily(amount, label, budgetType, dayStart);
                break;

            default:
                throw new ArgumentException($"Invalid Budget Entry Type {type}");
            }
            return(result);
        }