Example #1
0
        public void CreateMetadata_WithNoDisplayAttributeNorResource_ReturnsSpitDisplayName()
        {
            // arrange
            var model    = new { FirstName = "HelloWorld" };
            var provider = new ConventionalModelMetadataProvider(requireConventionAttribute: false);

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

            // assert
            Assert.Equal("First Name", metadata.DisplayName);
        }
Example #2
0
        public void CreateMetadata_WithDisplayAttributeMatchingResourceKey_ReturnsResourceValue()
        {
            // arrange
            var model = new TestModel {
                PropertyWithDisplayAttributeMatchingResourceKey = "HelloWorld"
            };
            var provider = new ConventionalModelMetadataProvider(requireConventionAttribute: false);

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

            // assert
            Assert.Equal("Property With Display Name From Resource File", metadata.DisplayName);
        }
Example #3
0
        public void CreateMetadata_WithDisplayAttributeNorResourceWithName_ReturnsSpecifiedName()
        {
            // arrange
            var model = new TestModel {
                PropertyWithDisplayAttributeHavingName = "HelloWorld"
            };
            var provider = new ConventionalModelMetadataProvider(requireConventionAttribute: false);

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

            // assert
            Assert.Equal("Property That Has A Display Attribute With A Name", metadata.DisplayName);
        }