public void CreateMetadata_WithNoDisplayAttributeNorResource_ReturnsSpitDisplayName()
        {
            var model = new {FirstName = "HelloWorld"};
            var provider = new ConventionalModelMetadataProvider(false);

            var metadata = provider.GetMetadataForProperty(() => model, model.GetType(), "FirstName");

            Assert.Equal("First Name", metadata.DisplayName);
        }
        public void CreateMetadata_WithDisplayAttributeMatchingResourceKey_ReturnsResourceValue()
        {
            var model = new TestModel {PropertyWithDisplayAttributeMatchingResourceKey = "HelloWorld"};
            var provider = new ConventionalModelMetadataProvider(false);

            var metadata = provider.GetMetadataForProperty(() => model, model.GetType(),
                "PropertyWithDisplayAttributeMatchingResourceKey");

            Assert.Equal("Property With Display Name From Resource File", metadata.DisplayName);
        }
        public void CreateMetadata_WithDisplayAttributeNorResourceWithName_ReturnsSpecifiedName()
        {
            var model = new TestModel {PropertyWithDisplayAttributeHavingName = "HelloWorld"};
            var provider = new ConventionalModelMetadataProvider(false);

            var metadata = provider.GetMetadataForProperty(() => model, model.GetType(),
                "PropertyWithDisplayAttributeHavingName");

            Assert.Equal("Property That Has A Display Attribute With A Name", metadata.DisplayName);
        }
        public void CreateMetadata_WithFullDisplayAttribute_ReturnsResourceValue()
        {
            var model = new TestModel {PropertyWithFullDisplayAttribute = "HelloWorld"};
            var provider = new ConventionalModelMetadataProvider(false);

            var metadata = provider.GetMetadataForProperty(() => model, model.GetType(),
                "PropertyWithFullDisplayAttribute");

            Assert.Equal("Property with full display attribute.", metadata.DisplayName);
        }
        public void CreateMetadata_WithPropertyMatchingResourceKey_ReturnsResourceValue()
        {
            // arrange
            var model = new TestModel { PropertyWithMatchingResourceKey = "HelloWorld" };
            var provider = new ConventionalModelMetadataProvider(requireConventionAttribute: false);

            // act
            var metadata = provider.GetMetadataForProperty(() => model, model.GetType(), "PropertyWithMatchingResourceKey");

            // assert
            Assert.Equal("Property With Property Name Matching Resource File", metadata.DisplayName);
        }
 public void Ctor_WithRequireAttribute_SetsProperty()
 {
     var provider = new ConventionalModelMetadataProvider(true);
     Assert.Equal(true, provider.RequireConventionAttribute);
 }