public void ShouldDetectInvalidAirlineNumber()
        {
            var fakeValidator = new Mock<IAirlineMembershipNumberValidator>();
            fakeValidator.Setup(x => x.IsValid(It.IsAny<string>())).Returns(false);

            var a = new CreditCardApplication();

            var sut = new ApplicationDetailsValidator(fakeValidator.Object);

            var errors = sut.Validate(a);

            Assert.That(errors, Has.Exactly(1).EqualTo("Airline membership number is invalid"));
        }
        public void ShouldDetectUseAirlineValidatorToCheckNumber()
        {
            var fakeValidator = new Mock<IAirlineMembershipNumberValidator>();

            var a = new CreditCardApplication
            {
                AirlineFrequentFlyerNumber = "x123"
            };

            var sut = new ApplicationDetailsValidator(fakeValidator.Object);

            sut.Validate(a);

            fakeValidator.Verify(x => x.IsValid("x123"),Times.Once());
        }
        public void ShouldDetectBlankName()
        {
            var fakeValidator = new Mock<IAirlineMembershipNumberValidator>();

            var a = new CreditCardApplication
                                          {
                                              ApplicantName=""
                                          };

            var sut = new ApplicationDetailsValidator(fakeValidator.Object);

            var errors = sut.Validate(a);

            Assert.That(errors,Has.Exactly(1).EqualTo("Name cannot be blank."));
        }
        public void ShouldValidateInCorrectApplication()
        {
            // Example of internal classes being integration tested together

            var sut = new ApplicationDetailsValidator(new AirlineMembershipNumberValidator());

            var a = new CreditCardApplication
            {
                ApplicantName = "Lisa",
                ApplicantAgeInYears = 44,
                AirlineFrequentFlyerNumber = "badnumber"
            };
            var errors = sut.Validate(a);

            Assert.That(errors, Is.Not.Empty);
        }