public void GetMortgageShouldReturnFromRepository()
        {
            var mockRepo        = new Mock <IMortgageRepo>();
            var fakemortagedata = new List <Mortgage> {
                new Mortgage
                {
                    CancellationFee    = (decimal)259.99,
                    EffectiveEndDate   = DateTime.UtcNow,
                    EffectiveStartDate = DateTime.UtcNow,
                    EstablishmentFee   = (decimal)259.99,
                    InterestRepayment  = (InterestRepayment)Enum.Parse(typeof(InterestRepayment), "InterestOnly"),
                    MortgageId         = 1,
                    MortgageType       = (MortgageType)Enum.Parse(typeof(MortgageType), "Fixed"),
                    Name          = "Fixed Home Loan (Interest Only)",
                    TermsInMonths = 12
                }
            };

            mockRepo.Setup(x => x.GetAllMortgages()).Returns(fakemortagedata);
            var msMortgageService = new MortgageService(mockRepo.Object);

            //Act
            var response = msMortgageService.GetAllMortgages();

            //Assert
            Assert.AreEqual(fakemortagedata, response);
        }
Exemplo n.º 2
0
        public void GetAllMortgages_ValidTest()
        {
            var mortgageList = mortgageService.GetAllMortgages();
            var controller   = new MortgageController();

            var result = controller.Get() as List <Dto.Mortgage>;


            Assert.AreEqual(mortgageList.Count, result.Count);
        }
Exemplo n.º 3
0
        private IEnumerable <Dto.Mortgage> GetFromCache()
        {
            ObjectCache cache = MemoryCache.Default;

            if (cache.Get("MortgageData") is List <Dto.Mortgage> mortgageData)
            {
                return(mortgageData);
            }

            var mortgageService = new MortgageService();

            mortgageData = mortgageService.GetAllMortgages();
            //Cache mortgageData for 24 hours
            CacheItemPolicy policy = new CacheItemPolicy {
                AbsoluteExpiration = DateTimeOffset.Now.AddHours(24)
            };

            cache.Add("MortgageData", mortgageData, policy);

            return(mortgageData);
        }
Exemplo n.º 4
0
        //GET: api/Mortgage/5
        public Dto.Mortgage Get(int id)
        {
            var mortgageService = new MortgageService();

            return(mortgageService.GetAllMortgages().FirstOrDefault(x => x.MortgageId == id));
        }
Exemplo n.º 5
0
        [CacheWebApi(Duration = 1440)] //Cache the response to 24 hours
        public IEnumerable <Dto.Mortgage> Get()
        {
            var mortgageService = new MortgageService();

            return(mortgageService.GetAllMortgages().OrderBy(m => m.MortgageType).ThenBy(n => n.InterestRate));
        }
 public void TestGetMortage()
 {
     MortgageService Mc      = new MortgageService();
     var             results = Mc.GetAllMortgages();
 }
        // GET: api/Mortgage
        public IEnumerable <Dto.Mortgage> Get()
        {
            var mortgageService = new MortgageService();

            return(mortgageService.GetAllMortgages());
        }
 // GET: api/Mortgage
 public IEnumerable <Dto.Mortgage> Get()
 {
     return(mortgageService.GetAllMortgages());
 }
        public void MortgageTypes_Test()
        {
            var list = _mortgageService.GetAllMortgages();

            Assert.IsTrue(list.Count > 0);
        }