コード例 #1
0
		public void ShouldDeclineWhenTooYoung()
		{
			var fakeCreditHistoryChecker = new Mock<ICreditHistoryChecker>();

			fakeCreditHistoryChecker.Setup(
				 x => x.CheckCreditHistory(It.IsAny<string>(), It.IsAny<string>()))
				 .Returns(true);

			var sut = new LoanApplicationScorer(fakeCreditHistoryChecker.Object);

			var application = new LoanApplication
			{
				Age = 21
			};

			sut.ScoreApplication(application);

			Assert.That(application.IsAccepted, Is.False);
		}
コード例 #2
0
		public void ShouldDeclineWhenNotTooYoungAndWealthyButPoorCredit()
		{
			var fakeCreditHistoryChecker = new Mock<ICreditHistoryChecker>();

			fakeCreditHistoryChecker.Setup(
				 x => x.CheckCreditHistory(It.IsAny<string>(), It.IsAny<string>()))
				 .Returns(false);

			var sut = new LoanApplicationScorer(fakeCreditHistoryChecker.Object);

			var application = new LoanApplication
			{
				AnnualIncome = 1000000.01m,
				Age = 22
			};

			sut.ScoreApplication(application);

			Assert.That(application.IsAccepted, Is.False);
		}
コード例 #3
0
		public void ShouldAcceptWhenYoungButWealthy()
		{
			var fakeCreditHistoryChecker = new Mock<ICreditHistoryChecker>();

			fakeCreditHistoryChecker.Setup(
				 x => x.CheckCreditHistory(It.IsAny<string>(), It.IsAny<string>()))
				 .Returns(true);

			var sut = new LoanApplicationScorer(fakeCreditHistoryChecker.Object);

			var application = new LoanApplication
			{
				AnnualIncome = 1000000.01m,
				Age = 21
			};

			sut.ScoreApplication(application);

			Assert.That(application.IsAccepted, Is.True);
		}