Ejemplo n.º 1
0
        public DataAnnotationsValidatorFixture()
        {
            this.propertyValidator1 =
                A.Fake <IPropertyValidator>();

            this.propertyValidator2 =
                A.Fake <IPropertyValidator>();

            this.validatableObjectAdapter =
                A.Fake <IValidatableObjectAdapter>();

            this.validatorFactory =
                A.Fake <IPropertyValidatorFactory>();

            A.CallTo(() => this.validatorFactory.GetValidators(typeof(ModelUnderTest)))
            .Returns(new[] { this.propertyValidator1, this.propertyValidator2 });

            this.validator =
                new DataAnnotationsValidator(typeof(ModelUnderTest), this.validatorFactory, this.validatableObjectAdapter);

            var adapterFactory = new DefaultPropertyValidatorFactory(new IDataAnnotationsValidatorAdapter[]
            {
                new RangeValidatorAdapter(),
                new RegexValidatorAdapter(),
                new RequiredValidatorAdapter(),
                new StringLengthValidatorAdapter(),
                new OopsAdapter()
            });

            var adapter = A.Fake <IValidatableObjectAdapter>();

            this.factory = new DataAnnotationsValidatorFactory(adapterFactory, adapter);
        }
        public DataAnnotationsValidatorFixture()
        {
            this.propertyValidator1 =
                A.Fake<IPropertyValidator>();

            this.propertyValidator2 =
                A.Fake<IPropertyValidator>();

            this.validatableObjectAdapter =
                A.Fake<IValidatableObjectAdapter>();

            this.validatorFactory =
                A.Fake<IPropertyValidatorFactory>();

            A.CallTo(() => this.validatorFactory.GetValidators(typeof(ModelUnderTest)))
               .Returns(new[] { this.propertyValidator1, this.propertyValidator2 });

            this.validator =
                new DataAnnotationsValidator(typeof(ModelUnderTest), this.validatorFactory, this.validatableObjectAdapter);

            var adapterFactory = new DefaultPropertyValidatorFactory(new IDataAnnotationsValidatorAdapter[]
            {
                new RangeValidatorAdapter(),
                new RegexValidatorAdapter(),
                new RequiredValidatorAdapter(),
                new StringLengthValidatorAdapter(),
                new OopsAdapter()
            });

            var adapter = A.Fake<IValidatableObjectAdapter>();

            this.factory = new DataAnnotationsValidatorFactory(adapterFactory, adapter);
        }
        public DataAnnotationsValidatorFixture()
        {
            this.propertyValidator1 =
                A.Fake <IPropertyValidator>();

            this.propertyValidator2 =
                A.Fake <IPropertyValidator>();

            this.validatableObjectAdapter =
                A.Fake <IValidatableObjectAdapter>();

            this.validatorFactory =
                A.Fake <IPropertyValidatorFactory>();

            A.CallTo(() => this.validatorFactory.GetValidators(typeof(ModelUnderTest)))
            .Returns(new[] { this.propertyValidator1, this.propertyValidator2 });

            this.validator =
                new DataAnnotationsValidator(typeof(ModelUnderTest), this.validatorFactory, this.validatableObjectAdapter);
        }
        public DataAnnotationsValidatorFixture()
        {
            this.propertyValidator1 =
                A.Fake<IPropertyValidator>();

            this.propertyValidator2 =
                A.Fake<IPropertyValidator>();

            this.validatableObjectAdapter =
                A.Fake<IValidatableObjectAdapter>();

            this.validatorFactory =
                A.Fake<IPropertyValidatorFactory>();

            A.CallTo(() => this.validatorFactory.GetValidators(typeof(ModelUnderTest)))
               .Returns(new[] { this.propertyValidator1, this.propertyValidator2 });

            this.validator =
                new DataAnnotationsValidator(typeof(ModelUnderTest), this.validatorFactory, this.validatableObjectAdapter);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataAnnotationsValidator"/> class.
 /// </summary>
 /// <param name="typeForValidation">The type for validation.</param>
 /// <param name="factory">The <see cref="IPropertyValidatorFactory"/> instance that should be used by the validator.</param>
 /// <param name="validatableObjectAdapter">The <see cref="validatableObjectAdapter"/> instance that should be used by the validator.</param>
 public DataAnnotationsValidator(Type typeForValidation, IPropertyValidatorFactory factory, IValidatableObjectAdapter validatableObjectAdapter)
 {
     this.ModelType = typeForValidation;
     this.validatableObjectAdapter = validatableObjectAdapter;
     this.validators = factory.GetValidators(typeForValidation);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataAnnotationsValidator"/> class.
 /// </summary>
 /// <param name="typeForValidation">The type for validation.</param>
 /// <param name="factory">The <see cref="IPropertyValidatorFactory"/> instance that should be used by the validator.</param>
 /// <param name="validatableObjectAdapter">The <see cref="validatableObjectAdapter"/> instance that should be used by the validator.</param>
 public DataAnnotationsValidator(Type typeForValidation, IPropertyValidatorFactory factory, IValidatableObjectAdapter validatableObjectAdapter)
 {
     this.ModelType = typeForValidation;
     this.validatableObjectAdapter = validatableObjectAdapter;
     this.validators = factory.GetValidators(typeForValidation);
 }
Ejemplo n.º 7
0
 public DataAnnotationsValidator(IValidatableObjectAdapter validatableObjectAdapter, IPropertyValidatorFactory propertyValidatorFactory)
 {
     _validatableObjectAdapter = validatableObjectAdapter;
     _propertyValidatorFactory = propertyValidatorFactory;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataAnnotationsValidatorAdapter"/> class.
 /// </summary>
 /// <param name="factory">The <see cref="IPropertyValidatorFactory"/> instance that should be used by the factory.</param>
 /// <param name="validatableObjectAdapter">The <see cref="validatableObjectAdapter"/> instance that should be used by the factory.</param>
 public DataAnnotationsValidatorFactory(IPropertyValidatorFactory factory, IValidatableObjectAdapter validatableObjectAdapter)
 {
     this.factory = factory;
     this.validatableObjectAdapter = validatableObjectAdapter;
 }