Exemplo n.º 1
0
        public void CanSupportWeeklyBudgetEntries()
        {
            var entry1 = new BudgetEntryWeekly(100, "EveryWeek", budgetType: BudgetType.Personal, period: 1, start: "Jan 4");

            _budget.AddEntry(entry1);
            Assert.That(_budget.MonthlyExpenses(1), Is.EqualTo(400));
            Assert.That(_budget.MonthlyExpenses(2), Is.EqualTo(400));
            Assert.That(_budget.TotalExpenses, Is.EqualTo(5200));
        }
Exemplo n.º 2
0
        public void CanSupportSimpleWeeklyBudgetEntriesWithLimit()
        {
            var entry1 = new BudgetEntryWeekly(681, "WA Unemployment", BudgetType.Income_Unemployment, start: "Feb 11", period: 1, max: 1);

            _budget.AddEntry(entry1);
            Assert.That(_budget.MonthlyIncome(1), Is.EqualTo(0.0));
            Assert.That(_budget.MonthlyIncome(2), Is.EqualTo(681.00));
            Assert.That(_budget.MonthlyIncome(3), Is.EqualTo(0.0));
            Assert.That(_budget.TotalIncome, Is.EqualTo(681.00));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void WeeklySerializationSupportsMax()
        {
            var entry1 = new BudgetEntryWeekly(10, "Weekly", BudgetType.Personal, 1, "Jan 4", max: 6);

            _budget.AddEntry(entry1);
            var budget = _budget;

            Assert.That(budget.TotalExpenses, Is.EqualTo(60.00));
            Assert.That(budget.MonthlyExpenses(1), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(2), Is.EqualTo(20.00));
        }
Exemplo n.º 5
0
        public void WeeklySerializeWorksForAllYears()
        {
            var entry1 = new BudgetEntryWeekly(10, "Weekly", BudgetType.Personal, 1, "Oct 12, 1955");

            _budget.AddEntry(entry1);
            var budget = _budget;

            Assert.That(budget.TotalExpenses, Is.EqualTo(120.00));
            Assert.That(budget.MonthlyExpenses(9), Is.EqualTo(0.00));
            Assert.That(budget.MonthlyExpenses(10), Is.EqualTo(30.00));
            Assert.That(budget.MonthlyExpenses(11), Is.EqualTo(50.00));
            Assert.That(budget.MonthlyExpenses(12), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(1), Is.EqualTo(0.00));
        }
Exemplo n.º 6
0
        public void CanSupportWeeklyBudgetEntriesWithLimit()
        {
            var entry1 = new BudgetEntryWeekly(681, "WA Unemployment", BudgetType.Income_Unemployment, start: "Feb 11", period: 1, max: 26);

            _budget.AddEntry(entry1);
            Assert.That(_budget.MonthlyTotal(1), Is.EqualTo(0.0));
            Assert.That(_budget.MonthlyTotal(2), Is.EqualTo(3 * 681.00));
            Assert.That(_budget.MonthlyTotal(3), Is.EqualTo(4 * 681.00));
            Assert.That(_budget.MonthlyTotal(4), Is.EqualTo(5 * 681.00));
            Assert.That(_budget.MonthlyTotal(5), Is.EqualTo(4 * 681.00));
            Assert.That(_budget.MonthlyTotal(6), Is.EqualTo(4 * 681.00));
            Assert.That(_budget.MonthlyTotal(7), Is.EqualTo(5 * 681.00));
            Assert.That(_budget.MonthlyTotal(8), Is.EqualTo(1 * 681.00));
            Assert.That(_budget.MonthlyTotal(9), Is.EqualTo(0.0));
            Assert.That(_budget.TotalIncome, Is.EqualTo(17706));
        }
Exemplo n.º 7
0
        public void WeeklySerialization()
        {
            var entry1 = new BudgetEntryWeekly(10, "Weekly", BudgetType.Personal, 1, "Jan 4");

            _budget.AddEntry(entry1);
            var budget = _budget;

            Assert.That(budget.TotalExpenses, Is.EqualTo(520.00));
            Assert.That(budget.MonthlyExpenses(1), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(2), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(3), Is.EqualTo(50.00));
            Assert.That(budget.MonthlyExpenses(4), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(5), Is.EqualTo(50.00));
            Assert.That(budget.MonthlyExpenses(6), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(7), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(8), Is.EqualTo(50.00));
            Assert.That(budget.MonthlyExpenses(9), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(10), Is.EqualTo(40.00));
            Assert.That(budget.MonthlyExpenses(11), Is.EqualTo(50.00));
            Assert.That(budget.MonthlyExpenses(12), Is.EqualTo(40.00));
        }