예제 #1
0
        public void CalculateRest_PostitiveIncomeAndPositiveExpenses_ResultOfIncomeMinusExpenses()
        {
            var calc   = new BudgetCalculator();
            var result = calc.CalculateRest(income, expenses);

            Assert.That(result, Is.EqualTo(15444));
        }
예제 #2
0
 public SummaryMailRenderer(
     Db db,
     BudgetCalculator budgetCalculator,
     SumCalculator sumCalculator)
 {
     _sumCalculator    = sumCalculator;
     _budgetCalculator = budgetCalculator;
     _db = db;
 }
예제 #3
0
 void Awake()
 {
     _currentBudget = _budgetParameters.StartBudget;
     UpdateMaxBudget(_currentBudget);
     _minLimit    = _budgetParameters.LowestBudget;
     _periodsData = new List <BudgetPeriodData>();
     _analyzer    = new BudgetAnalyzer(_budgetParameters.DebtsLastCount);
     _calculator  = new BudgetCalculator(_budgetParameters);
     _allocator.BudgetAllocated += OnBudgetAllocated;
     _collector.DebtCountBorder  = _budgetParameters.DebtsLastCount;
     _allPeriods       = 0;
     _processedPeriods = 0;
     CheckNewForecast(true);
 }
        public void CalculateBudget_InvalidInput_LogsErrors()
        {
            var transferables = new List <ITransferable>
            {
                new Expense {
                    Name = "Hyra", Value = 5200
                },
                new Expense {
                    Name = "El", Value = 300
                },
                new Expense {
                    Name = "Netflix", Value = 89
                },
                new Expense {
                    Name = "Spotify", Value = 99
                },
                new Expense {
                    Name = "Gym", Value = 400
                },
                new Expense {
                    Name = "Mat", Value = 1600
                },
                new Expense {
                    Name = "Drömresa", Value = 60000
                },
                new CalculatedExpense {
                    Name = "Sparande", Percent = 200
                },
                new CalculatedExpense {
                    Name = "Dator", Percent = 5
                },
                new CalculatedExpense {
                    Name = "Kläder", Percent = 5
                },
                new CalculatedExpense {
                    Name = "Pension", Percent = 75
                }
            };

            decimal actual = BudgetCalculator.CalculateBudget(transferables);

            Assert.Zero(actual);
        }
예제 #5
0
        public async Task <ActionResult> SummaryMailPreview()
        {
            var currentUser = await GetCurrentUser();

            var requestUrl = Request.Url;

            if (requestUrl == null)
            {
                throw new Exception("Request.Url is null. This should not be possible at this point.");
            }

            var budgetCalculator = new BudgetCalculator(Db, await GetCurrentClient());
            var sumCalculator    = new SumCalculator(Db, await GetCurrentClient());

            var summaryMailRenderer = new SummaryMailRenderer(Db, budgetCalculator, sumCalculator);
            var summaryMail         = await summaryMailRenderer.Render(currentUser);

            return(View(new SummaryMailPreviewViewModel
            {
                Html = summaryMail
            }));
        }
        public void CalculateBudget_EmptyList_ReturnZeroG()
        {
            decimal actual = BudgetCalculator.CalculateBudget(new List <ITransferable>());

            Assert.Zero(actual);
        }
        public void CalculateBudget_NullList_ReturnZero()
        {
            decimal actual = BudgetCalculator.CalculateBudget(null);

            Assert.Zero(actual);
        }
        public void CalculateBudget_Positive_ReturnBalance(decimal expected)
        {
            var transferables = new List <ITransferable>
            {
                new Income {
                    Name = "Lön", Value = 12000
                },
                new Income {
                    Name = "Bidrag", Value = 1200
                },
                new Income {
                    Name = "Gåva", Value = 600
                },
                new Income {
                    Name = "Försäljning", Value = 450.50m
                },
                new Income {
                    Name = "SMS-lån", Value = 10000
                },
                new Income {
                    Value = 100
                },
                new Expense {
                    Name = "Hyra", Value = 5200
                },
                new Expense {
                    Name = "El", Value = -300
                },
                new Expense {
                    Name = "Netflix", Value = 89
                },
                new Expense {
                    Name = "Spotify", Value = 99
                },
                new Expense {
                    Name = "Gym", Value = 400
                },
                new Expense {
                    Name = "Mat", Value = 1600
                },
                new Expense {
                    Name = "Drömresa", Value = 60000
                },
                new CalculatedExpense {
                    Name = "Sparande", Percent = 20
                },
                new CalculatedExpense {
                    Name = "Dator", Percent = 5
                },
                new CalculatedExpense {
                    Name = "Kläder", Percent = 5
                },
                new CalculatedExpense {
                    Name = "Pension", Percent = 75
                }
            };

            decimal actual = BudgetCalculator.CalculateBudget(transferables);

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