示例#1
0
 public ActionResult Verify(Customer customer)
 {
     var isEligible = _privillageCustomerService.IsEligible(customer);
     if (isEligible)
     {
         return RedirectToAction("Successful");
     }
     return RedirectToAction("Declined");
 }
        public void ShouldRejectWhenNormalSalesAndLessTimePeriodWithStocksly()
        {
            var mockHistoryChecker = new Mock<ICreditHistoryChecker>();
            mockHistoryChecker.Setup(x => x.CheckCreditHistory(It.IsAny<int>())).Returns(true);
            var sut = new PrivillageCustomerService(mockHistoryChecker.Object);
            var customer = new Customer { Id = 1, NoOfYearsWithStocksly = 8, AnnualIncome = 10000 };

            var isEligible = sut.IsEligible(customer);

            Assert.That(isEligible, Is.False);
        }
        public void ShouldRejectWithGreatSalesAndWithStockslyForALongPeriodButBadCredit()
        {
            var mockHistoryChecker = new Mock<ICreditHistoryChecker>();
            mockHistoryChecker.Setup(x => x.CheckCreditHistory(It.IsAny<int>())).Returns(false);
            var sut = new PrivillageCustomerService(mockHistoryChecker.Object);
            var customer = new Customer { Id = 1, NoOfYearsWithStocksly = 14, AnnualIncome = 10000000 };

            var isEligible = sut.IsEligible(customer);

            Assert.That(isEligible, Is.False);
        }
        public void ShouldApproveWhenWithStocklyForALongPeriodButNormalSales()
        {
            var mockHistoryCheker = new Mock<ICreditHistoryChecker>();
            mockHistoryCheker.Setup(x => x.CheckCreditHistory(It.IsAny<int>())).Returns(true);
            var sut = new PrivillageCustomerService(mockHistoryCheker.Object);
            var customer = new Customer { Id = 1, NoOfYearsWithStocksly = 12, AnnualIncome = 10000 };

            var isEligible = sut.IsEligible(customer);

            Assert.That(isEligible, Is.True);
        }