public void ComparingWithValueAccessReturningAccessFailureReturnsFailure()
        {
            ValueAccess valueAccess = new MockValueAccess(null, null, true);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.Equal);

            ValidationResults validationResults = validator.Validate("non null");

            Assert.IsFalse(validationResults.IsValid);
            Assert.AreEqual(1, ValidationTestHelper.GetResultsList(validationResults).Count);
        }
        public void ComparingNullForEqualityWithNonNullReturnsFailure()
        {
            ValueAccess valueAccess = new MockValueAccess("non null");
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.Equal);

            ValidationResults validationResults = validator.Validate(null);

            Assert.IsFalse(validationResults.IsValid);
        }
        public void ComparingNullForEqualWithNullReturnsSuccess()
        {
            ValueAccess valueAccess = new MockValueAccess(null);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.Equal);

            ValidationResults validationResults = validator.Validate(null);

            Assert.IsTrue(validationResults.IsValid);
        }
        public void NegatedComparisonReturnsExpectedResults()
        {
            ValueAccess valueAccess = new MockValueAccess(null);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.GreaterThanEqual, null, true);

            Assert.IsFalse(validator.Validate(5).IsValid);
            Assert.IsFalse(validator.Validate(null).IsValid);

            valueAccess = new MockValueAccess(6);
            validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.GreaterThanEqual, null, true);

            Assert.IsTrue(validator.Validate(5).IsValid);
            Assert.IsFalse(validator.Validate(6).IsValid);
            Assert.IsFalse(validator.Validate(7).IsValid);
            Assert.IsFalse(validator.Validate("string").IsValid);
            Assert.IsFalse(validator.Validate(null).IsValid);
        }
        public void ComparingComparableForGreaterThanEqualsReturnsExpectedResults()
        {
            ValueAccess valueAccess = new MockValueAccess(7);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.GreaterThanEqual);

            Assert.IsFalse(validator.Validate(5).IsValid);
            Assert.IsFalse(validator.Validate(6).IsValid);
            Assert.IsTrue(validator.Validate(7).IsValid);
            Assert.IsTrue(validator.Validate(8).IsValid);
            Assert.IsTrue(validator.Validate(9).IsValid);
        }
        public void ComparingWithUnknownOperatorFails()
        {
            ValueAccess valueAccess = new MockValueAccess(7);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, (ComparisonOperator)100);

            Assert.IsFalse(validator.Validate(5).IsValid);
            Assert.IsFalse(validator.Validate(6).IsValid);
            Assert.IsFalse(validator.Validate(7).IsValid);
            Assert.IsFalse(validator.Validate(8).IsValid);
            Assert.IsFalse(validator.Validate(9).IsValid);
        }
        public void ComparingComparableForLessThanWithLargerOfSameTypeReturnsSuccess()
        {
            ValueAccess valueAccess = new MockValueAccess(8);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.LessThan);

            ValidationResults validationResults = validator.Validate(7);

            Assert.IsTrue(validationResults.IsValid);
        }
        public void ComparingComparableForLessThanWithSmallerOfSameTypeReturnsFailure()
        {
            ValueAccess valueAccess = new MockValueAccess(6);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.LessThan);

            ValidationResults validationResults = validator.Validate(7);

            Assert.IsFalse(validationResults.IsValid);
        }
        public void ComparingComparableForLessThanWithNullReturnsFailure()
        {
            ValueAccess valueAccess = new MockValueAccess(null);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.LessThan);

            ValidationResults validationResults = validator.Validate("a string");

            Assert.IsFalse(validationResults.IsValid);
        }
        public void ComparingNonComparableForLessThanReturnsFailure()
        {
            ValueAccess valueAccess = new MockValueAccess(7);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.LessThan);

            ValidationResults validationResults = validator.Validate(new object());

            Assert.IsFalse(validationResults.IsValid);
        }
        public void ComparingNonNullForNonEqualityWithNonEqualReturnsSuccess()
        {
            ValueAccess valueAccess = new MockValueAccess(5);
            Validator validator = new ValueAccessComparisonValidator(valueAccess, ComparisonOperator.NotEqual);

            ValidationResults validationResults = validator.Validate("non null");

            Assert.IsTrue(validationResults.IsValid);
        }