Ejemplo n.º 1
0
        public void SuccessfulValidationIncrementsValidationSuccessCounterPerSecond()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper <object>  validator = new GenericValidatorWrapper <object>(new MockValidator(false), instrumentationProvider);

            validator.Validate(this);
            Assert.AreEqual(1L, validationSucceededPerSecond.RawValue);
        }
Ejemplo n.º 2
0
        public void CallingValidateIncrementsValidationCalledCounterPerSecond()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper <object>  validator = new GenericValidatorWrapper <object>(new MockValidator(false), instrumentationProvider);

            validator.Validate(this);
            Assert.AreEqual(1L, validationCallsPerSecCounter.RawValue);
        }
Ejemplo n.º 3
0
        private static Validator <T> WrapAndInstrumentValidator <T>(Validator validator, IConfigurationSource configurationSource)
        {
            GenericValidatorWrapper <T> validatorWrapper = new GenericValidatorWrapper <T>(validator);

            AttachInstrumentationListener(validatorWrapper, configurationSource);

            return(validatorWrapper);
        }
Ejemplo n.º 4
0
        public void FailedValidationIncrementsFailedValidationCounter()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper <object>  validator = new GenericValidatorWrapper <object>(new MockValidator(true), instrumentationProvider);

            validator.Validate(this);
            Assert.AreEqual(1L, validationFailures.RawValue);
        }
Ejemplo n.º 5
0
        public void CallingValidateIncrementsNumberOfValidationCallsCounter()
        {
            GenericValidatorWrapper <object> validator = new GenericValidatorWrapper <object>(new MockValidator(false),
                                                                                              new ValidationInstrumentationProvider
                                                                                                  (true, false, formatter));

            validator.Validate(this);
            Assert.AreEqual(1L, validationCallsCounter.RawValue);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Wraps a <see cref="Validator{T}"/> with a <see cref="GenericValidatorWrapper{T}"/> for instrumentation purposes.
        /// </summary>
        /// <typeparam name="T">Validator's target type.</typeparam>
        /// <param name="validator">Validator to wrap</param>
        /// <param name="unusedType">Not used in this implementation of WrapAndInstrumentValidator</param>
        /// <returns>A new, wrapped validator.</returns>
        protected virtual Validator <T> WrapAndInstrumentValidator <T>(Validator validator, Type unusedType)
        {
            var validatorWrapper = new GenericValidatorWrapper <T>(
                validator,
                InstrumentationProvider
                );

            return(validatorWrapper);
        }
Ejemplo n.º 7
0
        public void SuccessfulValidationIncrementsValidationSuccessCounterPerSecond()
        {
            GenericValidatorWrapper <object>  validator = new GenericValidatorWrapper <object>(new MockValidator(false));
            ValidationInstrumentationListener instrumentationListener = new ValidationInstrumentationListener(true, false, false, formatter);

            new ReflectionInstrumentationBinder().Bind(validator.GetInstrumentationEventProvider(), instrumentationListener);

            validator.Validate(this);
            Assert.AreEqual(1L, validationSucceededPerSecond.RawValue);
        }
Ejemplo n.º 8
0
        public void CallingValidateIncrementsNumberOfValidationCallsCounter()
        {
            GenericValidatorWrapper <object>  validator = new GenericValidatorWrapper <object>(new MockValidator(false));
            ValidationInstrumentationListener instrumentationListener = new ValidationInstrumentationListener(true, false, false, formatter);

            new ReflectionInstrumentationBinder().Bind(validator.GetInstrumentationEventProvider(), instrumentationListener);

            validator.Validate(this);
            Assert.AreEqual(1L, validationCallsCounter.RawValue);
        }
Ejemplo n.º 9
0
        public void SuccessIsDeterminedByWrappedValidator()
        {
            string target = "";

            MockValidator <object> wrappedValidator = new MockValidator <object>(false, "message");
            Validator <string>     validator        = new GenericValidatorWrapper <string>(wrappedValidator);

            ValidationResults validationResults = validator.Validate(target);

            Assert.IsTrue(validationResults.IsValid);
            Assert.AreSame(target, wrappedValidator.ValidatedTargets[0]);
        }
        public void SuccessIsDeterminedByWrappedValidator()
        {
            string target = "";

            MockValidator<object> wrappedValidator = new MockValidator<object>(false, "message");
            Validator<string> validator = new GenericValidatorWrapper<string>(wrappedValidator);

            ValidationResults validationResults = validator.Validate(target);

            Assert.IsTrue(validationResults.IsValid);
            Assert.AreSame(target, wrappedValidator.ValidatedTargets[0]);
        }
        public void FailureIsDeterminedByWrappedValidator()
        {
            string target = "";

            MockValidator<object> wrappedValidator = new MockValidator<object>(true, "message");
            Validator<string> validator = new GenericValidatorWrapper<string>(wrappedValidator);

            ValidationResults validationResults = validator.Validate(target);

            Assert.IsFalse(validationResults.IsValid);
            Assert.AreSame(target, wrappedValidator.ValidatedTargets[0]);
            IList<ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);
            Assert.AreEqual(1, resultsList.Count);
            Assert.AreEqual("message", resultsList[0].Message);
        }
Ejemplo n.º 12
0
        public void FailureIsDeterminedByWrappedValidator()
        {
            string target = "";

            MockValidator <object> wrappedValidator = new MockValidator <object>(true, "message");
            Validator <string>     validator        = new GenericValidatorWrapper <string>(wrappedValidator);

            ValidationResults validationResults = validator.Validate(target);

            Assert.IsFalse(validationResults.IsValid);
            Assert.AreSame(target, wrappedValidator.ValidatedTargets[0]);
            IList <ValidationResult> resultsList = ValidationTestHelper.GetResultsList(validationResults);

            Assert.AreEqual(1, resultsList.Count);
            Assert.AreEqual("message", resultsList[0].Message);
        }
Ejemplo n.º 13
0
        public void PercentageSuccessIsUpdated()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper <object>  ValidValidator          = new GenericValidatorWrapper <object>(new MockValidator(false), instrumentationProvider);
            GenericValidatorWrapper <object>  InValidValidator        = new GenericValidatorWrapper <object>(new MockValidator(true), instrumentationProvider);


            ValidValidator.Validate(this);
            ValidValidator.Validate(this);
            ValidValidator.Validate(this);

            Assert.AreEqual(100f, percentageValidationSuccesses.NextValue());

            InValidValidator.Validate(this);
            Assert.AreEqual(75f, percentageValidationSuccesses.NextValue());
        }
        public void FailedValidationIncrementsFailedValidationCounter()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper<object> validator = new GenericValidatorWrapper<object>(new MockValidator(true), instrumentationProvider);

            validator.Validate(this);
            Assert.AreEqual(1L, validationFailures.RawValue);
        }
        public void SuccessfulValidationIncrementsValidationSuccessCounterPerSecond()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper<object> validator = new GenericValidatorWrapper<object>(new MockValidator(false), instrumentationProvider);

            validator.Validate(this);
            Assert.AreEqual(1L, validationSucceededPerSecond.RawValue);
        }
        public void PercentageSuccessIsUpdated()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper<object> ValidValidator = new GenericValidatorWrapper<object>(new MockValidator(false), instrumentationProvider);
            GenericValidatorWrapper<object> InValidValidator = new GenericValidatorWrapper<object>(new MockValidator(true), instrumentationProvider);


            ValidValidator.Validate(this);
            ValidValidator.Validate(this);
            ValidValidator.Validate(this);

            Assert.AreEqual(100f, percentageValidationSuccesses.NextValue());

            InValidValidator.Validate(this);
            Assert.AreEqual(75f, percentageValidationSuccesses.NextValue());
        }
 public void CallingValidateIncrementsNumberOfValidationCallsCounter()
 {
     GenericValidatorWrapper<object> validator = new GenericValidatorWrapper<object>(new MockValidator(false),
                                                                                     new ValidationInstrumentationProvider
                                                                                         (true, false, formatter));
     validator.Validate(this);
     Assert.AreEqual(1L, validationCallsCounter.RawValue);
 }
        public void CallingValidateIncrementsValidationCalledCounterPerSecond()
        {
            ValidationInstrumentationProvider instrumentationProvider = new ValidationInstrumentationProvider(true, false, formatter);
            GenericValidatorWrapper<object> validator = new GenericValidatorWrapper<object>(new MockValidator(false), instrumentationProvider);

            validator.Validate(this);
            Assert.AreEqual(1L, validationCallsPerSecCounter.RawValue);
        }