public void When_the_age_is_above_or_equal_18_then_true_is_returned([Values(18, 30)] int age)
        {
            var customerMock = new CustomerMock(age);
            var validator    = new IsCustomerAdultValidator();

            bool isAdult = validator.Validate(customerMock);

            Assert.That(isAdult, Is.True);
        }
        public void When_the_age_is_below_18_then_false_is_returned()
        {
            var customerMock = new CustomerMock(10);
            var validator    = new IsCustomerAdultValidator();

            bool isAdult = validator.Validate(customerMock);

            Assert.That(isAdult, Is.False);
        }
Beispiel #3
0
        public void test3()
        {
            //Arrange
            var customer  = Mock.Of <ICustomer>(s => s.GetAge() == 21);
            var validator = new IsCustomerAdultValidator();

            //Act
            var result = validator.Validate(customer);

            //Assert
            Assert.IsTrue(result);
        }
Beispiel #4
0
        public void test1()
        {
            //Arrange
            var customer  = new CustomerMyMock(20);
            var validator = new IsCustomerAdultValidator();

            //Act
            var result = validator.Validate(customer);

            //Assert
            Assert.IsTrue(result);
        }
Beispiel #5
0
        public void test2()
        {
            //Arrange
            var customerMock = new Mock <ICustomer>();

            customerMock.Setup(s => s.GetAge()).Returns(21);
            ICustomer customer = customerMock.Object;

            var validator = new IsCustomerAdultValidator();

            //Act
            var result = validator.Validate(customer);

            //Assert
            Assert.IsTrue(result);
        }
        public void When_the_age_is_null_then_exception_should_be_thrown()
        {
            var validator = new IsCustomerAdultValidator();

            Assert.That(() => validator.Validate(null), Throws.ArgumentNullException);
        }