public void Constructor_FindsDisplayFormat_OverridingDataType() { // Arrange var dataType = new DataTypeAttribute(DataType.Time); // Has a non-null DisplayFormat. var displayFormat = new DisplayFormatAttribute(); var attributes = new Attribute[] { dataType, displayFormat, }; // Act var cache = new CachedDataAnnotationsMetadataAttributes(attributes); var result = cache.DisplayFormat; // Assert Assert.Same(displayFormat, result); }
public void Constructor_FindsExpectedAttribute( object attribute, Func <CachedDataAnnotationsMetadataAttributes, object> accessor) { // Arrange var attributes = new[] { attribute }; // Act var cache = new CachedDataAnnotationsMetadataAttributes(attributes); var result = accessor(cache); // Assert Assert.Same(attribute, result); }
public void Constructor_FindsDisplayFormat_FromDataType() { // Arrange var dataType = new DataTypeAttribute(DataType.Currency); var displayFormat = dataType.DisplayFormat; // Non-null for DataType.Currency. var attributes = new[] { dataType, }; // Act var cache = new CachedDataAnnotationsMetadataAttributes(attributes); var result = cache.DisplayFormat; // Assert Assert.Same(displayFormat, result); }
public void Constructor_FindsExpectedAttribute( Attribute attribute, Func<CachedDataAnnotationsMetadataAttributes, Attribute> accessor) { // Arrange var attributes = new[] { attribute }; // Act var cache = new CachedDataAnnotationsMetadataAttributes(attributes); var result = accessor(cache); // Assert Assert.Same(attribute, result); }
public void Constructor_DefaultsAllPropertiesToNull() { // Arrange var attributes = Enumerable.Empty <Attribute>(); // Act var cache = new CachedDataAnnotationsMetadataAttributes(attributes); // Assert Assert.Null(cache.Display); Assert.Null(cache.DisplayColumn); Assert.Null(cache.DisplayFormat); Assert.Null(cache.Editable); Assert.Null(cache.Required); }
public void Constructor_DefaultsAllPropertiesToNull() { // Arrange var attributes = Enumerable.Empty<Attribute>(); // Act var cache = new CachedDataAnnotationsMetadataAttributes(attributes); // Assert Assert.Null(cache.Display); Assert.Null(cache.DisplayColumn); Assert.Null(cache.DisplayFormat); Assert.Null(cache.Editable); Assert.Null(cache.Required); }
public void Constructor_FindsBinderTypeProviders() { // Arrange var providers = new[] { new TestBinderTypeProvider(), new TestBinderTypeProvider() }; // Act var cache = new CachedDataAnnotationsMetadataAttributes(providers); var result = cache.BinderTypeProviders.ToArray(); // Assert Assert.Equal(providers.Length, result.Length); for (var index = 0; index < providers.Length; index++) { Assert.Same(providers[index], result[index]); } }
public void Constructor_SetsDefaultValuesForAllProperties() { // Arrange var attributes = Enumerable.Empty <Attribute>(); // Act var cache = new CachedDataAnnotationsMetadataAttributes(attributes); // Assert Assert.Null(cache.DataType); Assert.Null(cache.Display); Assert.Null(cache.DisplayColumn); Assert.Null(cache.DisplayFormat); Assert.Null(cache.Editable); Assert.Null(cache.HiddenInput); Assert.Null(cache.Required); Assert.Null(cache.ScaffoldColumn); Assert.Null(cache.BinderMetadata); Assert.Null(cache.BinderModelNameProvider); Assert.Empty(cache.PropertyBindingPredicateProviders); }