public void GetDisplayName_ReturnsTypeName_WhenPropertyNameAndDisplayNameAreNull() { // Arrange var metadata = new TestModelMetadata(typeof(string)); // Act var result = metadata.GetDisplayName(); // Assert Assert.Equal("String", result); }
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); }
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); }
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); }
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); }