public void SimpleDisplayTextForNonNullClassWithNullDisplayColumnValueRevertsToDefaultBehavior() { // Arrange var provider = MakeProvider(); var model = new SimpleDisplayTextAttributeModel(); var metadata = provider.GetMetadataForType(() => model, typeof(SimpleDisplayTextAttributeModel)); // Act string result = metadata.SimpleDisplayText; // Assert Assert.Equal("42", result); // Falls back to the default logic of first property value }
public void SimpleDisplayTextForNonNullClassWithNonNullDisplayColumnValue() { // Arrange string expected = "Custom property display value"; var provider = MakeProvider(); var model = new SimpleDisplayTextAttributeModel { DisplayColumnProperty = expected }; var metadata = provider.GetMetadataForType(() => model, typeof(SimpleDisplayTextAttributeModel)); // Act string result = metadata.SimpleDisplayText; // Assert Assert.Equal(expected, result); }
public void SimpleDisplayTextForNonNullClassWithNullDisplayColumnValueRevertsToDefaultBehavior() { // Arrange DataAnnotationsModelMetadataProvider provider = new DataAnnotationsModelMetadataProvider(); SimpleDisplayTextAttributeModel model = new SimpleDisplayTextAttributeModel(); ModelMetadata metadata = provider.GetMetadataForType(() => model, typeof(SimpleDisplayTextAttributeModel)); // Act string result = metadata.SimpleDisplayText; // Assert Assert.AreEqual("42", result); // Falls back to the default logic of first property value }
public void SimpleDisplayTextForNonNullClassWithNonNullDisplayColumnValue() { // Arrange string expected = "Custom property display value"; DataAnnotationsModelMetadataProvider provider = new DataAnnotationsModelMetadataProvider(); SimpleDisplayTextAttributeModel model = new SimpleDisplayTextAttributeModel { DisplayColumnProperty = expected }; ModelMetadata metadata = provider.GetMetadataForType(() => model, typeof(SimpleDisplayTextAttributeModel)); // Act string result = metadata.SimpleDisplayText; // Assert Assert.AreEqual(expected, result); }