Esempio n. 1
0
        public SolarVsUtilityProjection CalculateFutureProjection(
            IYearlyKwhUsage solarEstimate,
            ProjectionParameters projectionParameters
            )
        {
            var projection      = new List <IYearlyKwhUsageCompare>();
            var utilityEstimate = projectionParameters.UtilityYear;

            var paidOffSolarEstimate = new YearlyKwhUsageFromAnnual(
                0, solarEstimate.TotalKiloWattHours
                );

            // Each year to project
            for (int i = 0; i < projectionParameters.YearsToProject; i++)
            {
                projection.Add(new YearlyKwhUsageCompare(
                                   FormulaHelpers.CompoundInterest(utilityEstimate.TotalCost, projectionParameters.PercentIncreasePerYear, 1, i),
                                   utilityEstimate.TotalKiloWattHours,
                                   i,
                                   // After financeYears, solar panels are no longer paid for
                                   i < projectionParameters.FinanceYears ?
                                   solarEstimate : paidOffSolarEstimate
                                   ));
            }

            return(new SolarVsUtilityProjection(solarEstimate, projection, projectionParameters.FinanceYears));
        }
Esempio n. 2
0
        public void ShouldCalculateCorrectInterest(
            double principal,
            double interestRate,
            int compoundsPerYear,
            int timeInYears,
            double expectedAmount
            )
        {
            var result = FormulaHelpers.CompoundInterest(principal, interestRate, compoundsPerYear, timeInYears);

            Assert.AreEqual(expectedAmount, result, .01);
        }
Esempio n. 3
0
        public void ShouldIncreaseProjectionByCorrectAmount(int yearsToProject)
        {
            var result = _subject.CalculateFutureProjection(
                GetSampleData(),
                new ProjectionParameters(GetSampleData(), yearsToProject, yearsToProject, PERCENT_INCREASE_PER_YEAR)
                );

            var sample = GetSampleData();

            for (int i = 1; i < yearsToProject; i++)
            {
                Assert.AreEqual(
                    FormulaHelpers.CompoundInterest(ORIGINAL_COST, PERCENT_INCREASE_PER_YEAR, 1, i),
                    result.FutureProjection[i].TotalCost,
                    .01,
                    $"{i} index Cost");
            }
        }