public void ShouldDeclineUnderAgeApplicant()
 {
     //Arrange
     var fakeService = new Mock<ICreditCardScoringService>();
     var sut = new CreditCardApplicationScorer(fakeService.Object);
     var application = new CreditCardApplication()
     {
         ApplicantAgeInYears = 20
     };
     //Act
     var result = sut.ScoreApplication(application);
     //Assert
     Assert.IsFalse(result);
 }
 public void ShouldAskScoringServiceForCreditCheck()
 {
     //Arrange
     var fakeService = new Mock<ICreditCardScoringService>();
     var sut = new CreditCardApplicationScorer(fakeService.Object);
     var application = new CreditCardApplication()
     {
         ApplicantAgeInYears = 22,
         ApplicantFullName = @"Brendan"
     };
     //Act
     sut.ScoreApplication(application);
     //Assert
     fakeService.Verify(x => x.HasGoodCreditHistory(@"Brendan"), Times.Once);
 }
 public void ShouldDeclineCorrectAgedApplicantWithPoorCreditHistory()
 {
     //Arrange
     var fakeService = new Mock<ICreditCardScoringService>();
     fakeService.Setup(x => x.HasGoodCreditHistory(It.IsAny<string>())).Returns(false);
     var sut = new CreditCardApplicationScorer(fakeService.Object);
     var application = new CreditCardApplication()
     {
         ApplicantAgeInYears = 22,
         ApplicantFullName = @"Brendan"
     };
     //Act
     var result = sut.ScoreApplication(application);
     //Assert
     Assert.IsFalse(result);
 }
        public bool ScoreApplication(CreditCardApplication application)
        {
            if (application.ApplicantAgeInYears <= 21) return false;

            return _scoringService.HasGoodCreditHistory(application.ApplicantFullName);
        }