diff --git a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataProviderTest.cs b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataProviderTest.cs index e6ae3f5b07..e38375680f 100644 --- a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataProviderTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.ComponentModel.DataAnnotations; +using System.Linq; using Xunit; namespace Microsoft.AspNet.Mvc.ModelBinding @@ -34,6 +35,36 @@ namespace Microsoft.AspNet.Mvc.ModelBinding Assert.False(provider.GetMetadataForProperty(null, type, "ScaffoldColumnFalse").ShowForEdit); } + [Fact] + public void HiddenInputWorksOnProperty() + { + // Arrange + var provider = new DataAnnotationsModelMetadataProvider(); + var metadata = provider.GetMetadataForType(modelAccessor: null, modelType: typeof(ClassWithHiddenProperties)); + var property = metadata.Properties.First(m => string.Equals("DirectlyHidden", m.PropertyName)); + + // Act + var result = property.HideSurroundingHtml; + + // Assert + Assert.True(result); + } + + // TODO #1000; enable test once we detect attributes on the property's type + public void HiddenInputWorksOnPropertyType() + { + // Arrange + var provider = new DataAnnotationsModelMetadataProvider(); + var metadata = provider.GetMetadataForType(modelAccessor: null, modelType: typeof(ClassWithHiddenProperties)); + var property = metadata.Properties.First(m => string.Equals("OfHiddenType", m.PropertyName)); + + // Act + var result = property.HideSurroundingHtml; + + // Assert + Assert.True(result); + } + private class ScaffoldColumnModel { public int NoAttribute { get; set; } @@ -44,5 +75,19 @@ namespace Microsoft.AspNet.Mvc.ModelBinding [ScaffoldColumn(scaffold: false)] public int ScaffoldColumnFalse { get; set; } } + + [HiddenInput(DisplayValue = false)] + private class HiddenClass + { + public string Property { get; set; } + } + + private class ClassWithHiddenProperties + { + [HiddenInput(DisplayValue = false)] + public string DirectlyHidden { get; set; } + + public HiddenClass OfHiddenType { get; set; } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs index df28e580e7..c484df8b49 100644 --- a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs +++ b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs @@ -164,53 +164,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding Assert.Equal(expectedResult, result); } - [Fact] - public void HiddenInputWorksOnProperty() - { - // Arrange - var provider = new DataAnnotationsModelMetadataProvider(); - var metadata = provider.GetMetadataForType(modelAccessor: null, modelType: typeof(ClassWithHiddenProperties)); - var property = metadata.Properties.First(m => string.Equals("DirectlyHidden", m.PropertyName)); - - // Act - var result = property.HideSurroundingHtml; - - // Assert - Assert.True(result); - } - - // TODO #1000; enable test once we detect attributes on the property's type - public void HiddenInputWorksOnPropertyType() - { - // Arrange - var provider = new DataAnnotationsModelMetadataProvider(); - var metadata = provider.GetMetadataForType(modelAccessor: null, modelType: typeof(ClassWithHiddenProperties)); - var property = metadata.Properties.First(m => string.Equals("OfHiddenType", m.PropertyName)); - - // Act - var result = property.HideSurroundingHtml; - - // Assert - Assert.True(result); - } - private class ClassWithDisplayableColumn { public string Property { get; set; } } - - [HiddenInput(DisplayValue = false)] - private class HiddenClass - { - public string Property { get; set; } - } - - private class ClassWithHiddenProperties - { - [HiddenInput(DisplayValue = false)] - public string DirectlyHidden { get; set; } - - public HiddenClass OfHiddenType { get; set; } - } } } \ No newline at end of file