Example #1
0
        // GET: Home
        public ActionResult Index()

        {
            InvestmentCalc inv = new InvestmentCalc();

            return(View(inv));
        }
Example #2
0
        public void TestCalcMethodInvestmentCalc1()
        {
            InvestmentCalc inv      = new InvestmentCalc(5000.0, 10, 5, 12);
            double         expected = 8235.05;
            double         actual   = inv.FutureValue;

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void TestCalcMethodInvestmentCalc3()
        {
            InvestmentCalc inv      = new InvestmentCalc(2000000.0, 5, 100, 2);
            double         expected = 115330078.13;
            double         actual   = inv.FutureValue;

            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public void TestCalcMethodInvestmentCalc2()
        {
            InvestmentCalc inv      = new InvestmentCalc(12000.0, 30, 40, 2);
            double         expected = 676170172.24;
            double         actual   = inv.FutureValue;

            Assert.AreEqual(expected, actual);
        }
Example #5
0
 public ActionResult Summary(InvestmentCalc inv)
 {
     if (ModelState.IsValid)
     {
         ViewBag.Info = "";
         return(View(inv));
     }
     else
     {
         ViewBag.Info = "Input is not valid";
     }
     return(View("Val"));
 }
Example #6
0
        public void TestTheFormula()
        {
            InvestmentCalc investment = new InvestmentCalc();
            double         principle  = 5000;
            int            years      = 10;
            double         intrest    = 0.05;
            int            numTimes   = 12;
            double         amount;
            double         FutureValue;
            double         nt   = numTimes * years;
            double         bace = (1 + (intrest / numTimes));

            amount      = System.Math.Pow(bace, nt);
            FutureValue = (principle * amount);
            Assert.AreEqual(FutureValue, 8235.0474884514);
        }
Example #7
0
 public IActionResult Summary(InvestmentCalc inv)
 {
     if (ModelState.IsValid)
     {
         //For now just display the result of the calculation
         ViewData["info"] = $"{inv.FutureValue}";
     }
     else
     {
         ViewData["Info"] = "Inputs are invalid.";
         //TODO: -5 need to go back to Index view and pass model if not valid.
         return(View("Index", inv));
     }
     //TODO: -5 need to pass model to Summary view
     return(View(inv));
 }
Example #8
0
        public void SomeTest()
        {
            // setup  for test
            int            compoundsPerYear = 80;
            int            loanYears        = 22;
            double         interestRate     = 7;
            double         principle        = 500000.00;
            InvestmentCalc testy            = new InvestmentCalc(compoundsPerYear, loanYears, interestRate, principle);

            //results making sure the rate does not change from input
            double expected = 7;
            double actual   = testy.Interest;

            //check
            Assert.AreEqual(expected, actual);
        }
Example #9
0
        public void SomeTest3()
        {
            // setup for test
            InvestmentCalc testy = new InvestmentCalc();

            testy.Interest  = 5;
            testy.CompPerYr = 2;
            testy.Years     = 30;
            testy.Principal = 500000.00;

            //results calculated and expected values from the internet calculator at "http://www.moneychimp.com/calculator///compound_interest_calculator.htm"
            double expected = 2199894.87;
            double actual   = testy.FutureValue;

            //check to see if values are within 0.001 of eachother or "=" for a decimal
            Assert.IsTrue((expected - actual < 0.001));
        }
Example #10
0
        public void SomeTest2()
        {
            // setup  for test
            int            compoundsPerYear = 80;
            int            loanYears        = 31;
            double         interestRate     = 7;
            double         principle        = 0;
            InvestmentCalc testy            = new InvestmentCalc(compoundsPerYear, loanYears, interestRate, principle);

            //results expect future value to be 0.00 due to the fact principle is 0
            double expected = 0;
            double actual   = testy.FutureValue;

            //check

            Assert.AreEqual(expected, actual);
        }
Example #11
0
 public ActionResult SubmitInvestment(InvestmentCalc ic)
 {
     if (ModelState.IsValid)
     {
         //TODO: -5 do not use ViewBag for this. That is what the model if for. Pass the model to the view instead. RJG
         // Individually assigning each variable in the viewbag as a string to output in the HTML
         ViewBag.Principal   = string.Format("Initial principal on Investment is {0:C}", ic.Principal);
         ViewBag.Years       = string.Format("Years of Investment is {0}", ic.Years);
         ViewBag.Interest    = string.Format("Interest on Investment is {0:P}", ic.Interest);
         ViewBag.CmpPerYr    = string.Format("Compounds per Year is {0}", ic.CmpPerYr);
         ViewBag.FutureValue = string.Format("Future value of Investment is {0:C}", ic.FutureValue);
     }
     else
     {
         ViewBag.Info = "Invalid input given, try again";
     }
     //TODO: return View(ic) instead here. RJG
     return(View("Index"));
 }
Example #12
0
/*         public IActionResult Summary()
 *              {
 *                  return View();
 *              }*/
        public IActionResult Summary(InvestmentCalc inv)
        {
            inv.Calc();
            return(View("Summary"));
        }