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 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); }
private static Validator <T> WrapAndInstrumentValidator <T>(Validator validator, IConfigurationSource configurationSource) { GenericValidatorWrapper <T> validatorWrapper = new GenericValidatorWrapper <T>(validator); AttachInstrumentationListener(validatorWrapper, configurationSource); return(validatorWrapper); }
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 CallingValidateIncrementsNumberOfValidationCallsCounter() { GenericValidatorWrapper <object> validator = new GenericValidatorWrapper <object>(new MockValidator(false), new ValidationInstrumentationProvider (true, false, formatter)); validator.Validate(this); Assert.AreEqual(1L, validationCallsCounter.RawValue); }
/// <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); }
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); }
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); }
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); }
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); }
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); }