Exemplo n.º 1
0
        public void CanSupportBiMonthlyBudgetEntries()
        {
            var _biMonthlyEntry = new BudgetEntryBiMonthly(40.00, 1, "Water Bill", BudgetType.Utilities_WaterSewerWaste);

            _budget.AddEntry(_biMonthlyEntry);
            Assert.That(_budget.TotalExpenses, Is.EqualTo(40.00 * 6));
            Assert.That(_budget.MonthlyExpenses(1), Is.EqualTo(40.00));
            Assert.That(_budget.MonthlyExpenses(2), Is.EqualTo(0.00));
        }
Exemplo n.º 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);
        }