public void ProvidesValidationResultsToValidationMethod()
        {
            Validator validator = new SelfValidationValidator(GetType().GetMethod("SelfValidationMethod", BindingFlags.NonPublic | BindingFlags.Instance));
            ValidationResults validationResults = new ValidationResults();

            validator.Validate(this, validationResults);

            Assert.AreSame(validationResults, suppliedValidationResults);
        }
        public void LogsOwnValidationFailureIfValidatedObjectIsANullReference()
        {
            Validator validator = new SelfValidationValidator(GetType().GetMethod("SelfValidationMethod", BindingFlags.NonPublic | BindingFlags.Instance));
            validator.Tag = "tag";
            ValidationResults validationResults = new ValidationResults();

            validator.Validate(null, validationResults);

            Assert.IsNull(suppliedValidationResults); // the self validation method should not have been called when validating null
            IList<ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);
            Assert.AreEqual(1, resultsList.Count);
            Assert.AreEqual(Resources.SelfValidationValidatorMessage, resultsList[0].Message);
            Assert.AreSame(null, resultsList[0].Key);
            Assert.AreSame("tag", resultsList[0].Tag);
            Assert.AreSame(null, resultsList[0].Target);
            Assert.AreSame(validator, resultsList[0].Validator);
        }
        public void LogsOwnValidationFailureIfValidationMethodThrows()
        {
            Validator validator = new SelfValidationValidator(GetType().GetMethod("ThrowingSelfValidationMethod", BindingFlags.NonPublic | BindingFlags.Instance));
            ValidationResults validationResults = new ValidationResults();

            validator.Validate(this, validationResults);

            Assert.IsNull(suppliedValidationResults);
            IList<ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);
            Assert.AreEqual(1, resultsList.Count);
            Assert.AreEqual(Resources.SelfValidationMethodThrownMessage, resultsList[0].Message);
        }