public void LabelForOverridden_NoBaseDisplayAttribute_NotOveridden_ReturnsUnmodifiedString() { var unmodifiedString = gds.LabelFor(m => m.NoBaseDisplayAttribute, false); var result = gds.LabelForOverridden(m => m.NoBaseDisplayAttribute, typeof(TestViewModel)); Assert.Equal(unmodifiedString.ToString(), result.ToString()); }
public static MvcHtmlString LabelForOverridden <TModel, TValue>(this Gds <TModel> gds, Expression <Func <TModel, TValue> > expression, Type type) { var baseType = typeof(TModel); if (type.BaseType != baseType) { throw new ArgumentException($"The Gds model type ({baseType}) must be the base type of the provided type ({type})"); } var labelFor = gds.LabelFor(expression, false); var propertyName = ExpressionHelper.GetExpressionText(expression); return(ReplaceDisplayString(labelFor, type, propertyName)); }