Esempio n. 1
0
        public void MortgageDataShouldNotBeNull()
        {
            var mortgages = mortgageRepo.GetAllMortgages();

            Assert.IsNotNull(mortgages, "Mortgage Data should not be null.");
            Assert.IsTrue(mortgages.Count > 0, "Mortgage Data count should not be zero.");
        }
Esempio n. 2
0
        public List <Mortgage> GetAllMortgages()
        {
            List <Mortgage> mortgages = null;

            try
            {
                mortgages = HttpRuntime.Cache["mortgages"] as List <Mortgage>;

                if (mortgages == null)
                {
                    mortgages = _mortgageRepo.GetAllMortgages();

                    HttpRuntime.Cache.Add("mortgages", mortgages, null, DateTime.Now.AddHours(24), Cache.NoSlidingExpiration, CacheItemPriority.High, new CacheItemRemovedCallback(ItemRemovedCallback));
                    log.Info("Mortgages added to cache.");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + ex.StackTrace);
            }

            return(mortgages);
        }
        public void Verify_GetAllMortgages_Repository()
        {
            List <Mortgage> mortgages = _mortgageRepo.GetAllMortgages();

            Assert.IsNotNull(mortgages);
            Assert.IsTrue(mortgages.Count > 0);

            // Test Mortgage Sorting Logic
            var firstMortgage = mortgages.First();

            Assert.AreEqual(firstMortgage.MortgageType, MortgageType.Variable);

            var variableMortgages = mortgages.Where(mt => mt.MortgageType == MortgageType.Variable).ToList();

            Assert.Less(variableMortgages.First <Mortgage>().InterestRate, variableMortgages.Last <Mortgage>().InterestRate);

            var lastMortgage = mortgages.Last();

            Assert.AreEqual(lastMortgage.MortgageType, MortgageType.Fixed);

            var fixedMortgages = mortgages.Where(mt => mt.MortgageType == MortgageType.Fixed).ToList();

            Assert.Less(fixedMortgages.First <Mortgage>().InterestRate, fixedMortgages.Last <Mortgage>().InterestRate);
        }
Esempio n. 4
0
 public List <Mortgage> GetAllMortgages()
 {
     return(_mortgageRepo.GetAllMortgages().OrderBy(x => x.MortgageType).ToList());
 }
Esempio n. 5
0
 public List <Mortgage> GetAllMortgages()
 {
     return(_mortgageRepo.GetAllMortgages());
 }