public void Metadata_should_be_same_which_is_passed_in_constructor() { var metadata = new Mock<ModelMetadataItemBase>(); var modelMetadata = new ExtendedModelMetadata(new Mock<ModelMetadataProvider>().Object, typeof (object),() => null, typeof (object), "foo", metadata.Object); Assert.Same(metadata.Object, modelMetadata.Metadata); }
public void Metadata_should_be_same_which_is_passed_in_constructor() { var metadata = new Mock <ModelMetadataItem>(); var modelMetadata = new ExtendedModelMetadata(new Mock <ModelMetadataProvider>().Object, typeof(object), () => null, typeof(object), "foo", metadata.Object); Assert.Same(metadata.Object, modelMetadata.Metadata); }
/// <summary> /// Creates the validator. /// </summary> /// <param name="modelMetadata">The model metadata.</param> /// <param name="context">The context.</param> /// <returns></returns> public ModelValidator CreateValidator(ExtendedModelMetadata modelMetadata, ControllerContext context) { Invariant.IsNotNull(modelMetadata, "modelMetadata"); Invariant.IsNotNull(context, "context"); return CreateValidatorCore(modelMetadata, context); }
protected override ModelMetadata CreateMetadata(IEnumerable <Attribute> attributes, Type containerType, Func <object> modelAccessor, Type modelType, string propertyName) { var extended = new ExtendedModelMetadata(); PopulateMetadata(extended); return(extended); }
public void GetValidators_should_return_validators_when_metadata_is_extended_metadata() { var builder = new ModelMetadataItemBuilder <string>(new ModelMetadataItem()); builder.Required().AsEmail(); var metadata = new ExtendedModelMetadata(new Mock <ModelMetadataProvider>().Object, GetType(), () => new DummyObject(), typeof(DummyObject), string.Empty, builder.Item); var validators = provider.GetValidators(metadata, new ControllerContext()); Assert.NotEmpty(validators); }
public void GetValidators_should_return_validators_when_metadata_is_extended_metadata() { var builder = new ModelMetadataItemBuilder<string>(new ModelMetadataItem()); builder.Required().AsEmail(); var metadata = new ExtendedModelMetadata(new Mock<ModelMetadataProvider>().Object, GetType(), () => new DummyObject(), typeof(DummyObject), string.Empty, builder.Item); var validators = provider.GetValidators(metadata, new ControllerContext()); Assert.NotEmpty(validators); }
/// <summary> /// Creates the validator. /// </summary> /// <param name="modelMetadata">The model metadata.</param> /// <param name="context">The context.</param> /// <returns></returns> protected override ModelValidator CreateValidatorCore(ExtendedModelMetadata modelMetadata, ControllerContext context) { return new ExtendedRequiredValidator(modelMetadata, context, this); }
/// <summary> /// Creates the validator. /// </summary> /// <param name="modelMetadata">The model metadata.</param> /// <param name="context">The context.</param> /// <returns></returns> protected abstract ModelValidator CreateValidatorCore(ExtendedModelMetadata modelMetadata, ControllerContext context);