示例#1
0
        public void GetDisplayName_ReturnsTypeName_WhenPropertyNameAndDisplayNameAreNull()
        {
            // Arrange
            var metadata = new TestModelMetadata(typeof(string));

            // Act
            var result = metadata.GetDisplayName();

            // Assert
            Assert.Equal("String", result);
        }
示例#2
0
        public void GetDisplayName_ReturnsPropertyName_WhenSetAndDisplayNameIsNull()
        {
            // Arrange
            var metadata = new TestModelMetadata(typeof(int), "Length", typeof(string));

            // Act
            var result = metadata.GetDisplayName();

            // Assert
            Assert.Equal("Length", result);
        }
示例#3
0
        public void GetDisplayName_ReturnsParameterName_WhenSetAndDisplayNameIsNull()
        {
            // Arrange
            var method    = typeof(CollectionImplementation).GetMethod(nameof(CollectionImplementation.Add));
            var parameter = method.GetParameters()[0]; // Add(string item)
            var metadata  = new TestModelMetadata(parameter);

            // Act
            var result = metadata.GetDisplayName();

            // Assert
            Assert.Equal("item", result);
        }
示例#4
0
        public void GetDisplayName_ReturnsDisplayName_IfSet()
        {
            // Arrange
            var metadata = new TestModelMetadata(typeof(int), "Length", typeof(string));

            metadata.SetDisplayName("displayName");

            // Act
            var result = metadata.GetDisplayName();

            // Assert
            Assert.Equal("displayName", result);
        }
示例#5
0
        public void GetDisplayName_ReturnsDisplayName_IfSet()
        {
            // Arrange
            var property = typeof(string).GetProperty(nameof(string.Length));
            var metadata = new TestModelMetadata(property, typeof(int), typeof(string));

            metadata.SetDisplayName("displayName");

            // Act
            var result = metadata.GetDisplayName();

            // Assert
            Assert.Equal("displayName", result);
        }