public void SimpleDisplayTextReturnsFirstPropertyValueForNonNullModel() { // Arrange SimpleDisplayTextModelWithoutToString model = new SimpleDisplayTextModelWithoutToString { FirstProperty = "First Property Value" }; EmptyModelMetadataProvider provider = new EmptyModelMetadataProvider(); ModelMetadata metadata = new ModelMetadata(provider, null, () => model, typeof(SimpleDisplayTextModelWithoutToString), null); // Act string result = metadata.SimpleDisplayText; // Assert Assert.AreEqual(model.FirstProperty, result); }
public void SimpleDisplayTextReturnsFirstPropertyNullDisplayTextForNonNullModelWithNullDisplayColumnPropertyValue() { // Arrange SimpleDisplayTextModelWithoutToString model = new SimpleDisplayTextModelWithoutToString(); EmptyModelMetadataProvider propertyProvider = new EmptyModelMetadataProvider(); ModelMetadata propertyMetadata = propertyProvider.GetMetadataForProperty(() => model.FirstProperty, typeof(SimpleDisplayTextModelWithoutToString), "FirstProperty"); propertyMetadata.NullDisplayText = "Null Display Text"; Mock <ModelMetadataProvider> provider = new Mock <ModelMetadataProvider>(); provider.Setup(p => p.GetMetadataForProperties(model, typeof(SimpleDisplayTextModelWithoutToString))) .Returns(new[] { propertyMetadata }); ModelMetadata metadata = new ModelMetadata(provider.Object, null, () => model, typeof(SimpleDisplayTextModelWithoutToString), null); // Act string result = metadata.SimpleDisplayText; // Assert Assert.Equal(propertyMetadata.NullDisplayText, result); }
public void SimpleDisplayTextReturnsFirstPropertyNullDisplayTextForNonNullModelWithNullDisplayColumnPropertyValue() { // Arrange SimpleDisplayTextModelWithoutToString model = new SimpleDisplayTextModelWithoutToString(); EmptyModelMetadataProvider propertyProvider = new EmptyModelMetadataProvider(); ModelMetadata propertyMetadata = propertyProvider.GetMetadataForProperty(() => model.FirstProperty, typeof(SimpleDisplayTextModelWithoutToString), "FirstProperty"); propertyMetadata.NullDisplayText = "Null Display Text"; Mock<ModelMetadataProvider> provider = new Mock<ModelMetadataProvider>(); provider.Setup(p => p.GetMetadataForProperties(model, typeof(SimpleDisplayTextModelWithoutToString))) .Returns(new[] { propertyMetadata }); ModelMetadata metadata = new ModelMetadata(provider.Object, null, () => model, typeof(SimpleDisplayTextModelWithoutToString), null); // Act string result = metadata.SimpleDisplayText; // Assert Assert.Equal(propertyMetadata.NullDisplayText, result); }
public void SimpleDisplayTextReturnsFirstPropertyValueForNonNullModel() { // Arrange SimpleDisplayTextModelWithoutToString model = new SimpleDisplayTextModelWithoutToString { FirstProperty = "First Property Value" }; EmptyModelMetadataProvider provider = new EmptyModelMetadataProvider(); ModelMetadata metadata = new ModelMetadata(provider, null, () => model, typeof(SimpleDisplayTextModelWithoutToString), null); // Act string result = metadata.SimpleDisplayText; // Assert Assert.Equal(model.FirstProperty, result); }