Ejemplo n.º 1
0
 public CreditCardApplicationEvaluator(IFrequentlyFlyerNumberValidator validator,
                                       FraudLookup fraudLookup = null)
 {
     _validator = validator
                  ?? throw new ArgumentNullException(nameof(validator));
     _fraudLookup = fraudLookup;
     _validator.ValidatorLookupPerformed += ValidatorLookupPerformed;
 }
Ejemplo n.º 2
0
        public void LinqToMocks()
        {
            // // Classic setup
            //var validator = new Mock<IFrequentlyFlyerNumberValidator>();
            //validator.Setup(x => x.ServiceInformation.License.LicenseKey)
            //    .Returns("OK");
            //validator.Setup(x => x.isValid(It.IsAny<string>()))
            //    .Returns(true);

            // LinqToMocks:
            IFrequentlyFlyerNumberValidator _validator =
                Mock.Of <IFrequentlyFlyerNumberValidator>(x =>
                                                          x.ServiceInformation.License.LicenseKey == "OK" &&
                                                          x.isValid(It.IsAny <string>()));

            sut = new CreditCardApplicationEvaluator(_validator);
            var application = new CreditCardApplication {
                Age = 25
            };

            CreditCardApplicationDecision decision = sut.Evaluate(application);

            Assert.Equal(CreditCardApplicationDecision.AutoDeclined, decision);
        }