Example #1
0
        public ActionResult CalculateMortgage(MortgageViewModel viewModel)
        {
            Mortgage            id          = this._mortgageRepository.GetId(viewModel.MortgageId);
            MortgageCalculation calculation = new MortgageCalculation();

            return(View(calculation.CalculateMortgage(id, viewModel.LoanAmount, viewModel.LoanTenure)));
        }
Example #2
0
        public void TestErrorCondition()
        {
            var vm = new MortgageViewModel();

            vm.PurchasePrice = -10000;
            Assert.AreEqual(vm[nameof(vm.PurchasePrice)], "Purchase Price must be a postiive value");
        }
        public void Home_IndexPost_ShouldRedirectToCalculateMortgage()
        {
            var mortgages = new List <Mortgage> {
                new Mortgage {
                    MortgageId = 1, InterestRate = 1, Name = "test"
                },
                new Mortgage {
                    MortgageId = 2, InterestRate = 1, Name = "test2"
                }
            };

            mockRepositoryMortgage = new Mock <IRepositoryBase <Mortgage> >();
            mockRepositoryMortgage.Setup(m => m.GetAll()).Returns(mortgages.AsEnumerable);

            HomeController controller = new HomeController(mockRepositoryMortgage.Object);

            Mock <Mortgage> mockMortgage = new Mock <Mortgage>();

            MortgageViewModel mortgageViewModel = new MortgageViewModel();

            mortgageViewModel.LoanAmount = 1000000;
            mortgageViewModel.LoanTenure = 10;
            mortgageViewModel.MortgageId = "9";

            RedirectToRouteResult result = (RedirectToRouteResult)controller.CalculateMortgage(mortgageViewModel) as RedirectToRouteResult;

            var viewModel = controller.ViewData.Model as Mortgage;

            Assert.IsNotNull(result);
        }
Example #4
0
        public void TestMortgageConstructor()
        {
            MortgageViewModel testMortgage = new MortgageViewModel(100000, 1000, 4, 30);

            Assert.AreEqual(99000, testMortgage.MortgageAmount);
            Assert.AreEqual(99000, testMortgage.TotalPrincipal);
        }
Example #5
0
        public ActionResult Index()
        {
            this._mortgageRepository.GetAll();
            IEnumerable <Mortgage> all   = this._mortgageRepository.GetAll();
            MortgageViewModel      model = new MortgageViewModel
            {
                MortgageList = all
            };

            return(base.View(model));
        }
        public void Home_Index_ShouldPassMortgagesToTheView()
        {
            var mortgages = new List <Mortgage> {
                new Mortgage {
                    MortgageId = 1
                },
                new Mortgage {
                    MortgageId = 2
                }
            };

            mockRepositoryMortgage = new Mock <IRepositoryBase <Mortgage> >();
            mockRepositoryMortgage.Setup(m => m.GetAll()).Returns(mortgages.AsQueryable());

            HomeController controller = new HomeController(mockRepositoryMortgage.Object);

            ViewResult        result   = controller.Index() as ViewResult;
            MortgageViewModel mortgage = (MortgageViewModel)result.ViewData.Model;

            Assert.IsNotNull(result);
            Assert.IsNotNull(mortgage);
        }
 public SearchDetailsViewModel(Mortgage mortgage, int searchId)
 {
     Mortgage = new MortgageViewModel(mortgage);
     SearchId = searchId;
 }
Example #8
0
        public void TestRightPercentage()
        {
            MortgageViewModel testMortgage = new MortgageViewModel(100000, 0, 4, 30);

            Assert.AreEqual(.42, Math.Round(testMortgage.TotalInterest / (testMortgage.TotalInterest + testMortgage.TotalPrincipal), 2));
        }
Example #9
0
        public void TestGraphInformation()
        {
            MortgageViewModel testMortgage = new MortgageViewModel(100000, 0, 4, 30);

            Assert.AreEqual(171871, Math.Round(testMortgage.TotalInterest + testMortgage.TotalPrincipal, 0));
        }
Example #10
0
        public void TestMonthlyPaymentCalculation()
        {
            MortgageViewModel testMortgage = new MortgageViewModel(100000, 0, 4, 30);

            Assert.AreEqual(477, Math.Round(testMortgage.MonthlyPayment, 0));
        }