Comments: ** Comment from web user: AB_dreeve **
A general example case is when I have a class which I override ToString() to return only 1 or 2 properties on my class, but my class might have many more properties. Losing the default formatting and the ability to display the additional properties is unfortunate because the additional property values is often important in why a test might fail.
For example:
public class ExcelSchemaDefinition {
public int Index { get; set; }
public string DataField { get; set; }
public string ColumnLabel { get; set; }
public int ColumnIndex { get; set; }
public string CellFormat { get; set; }
public string PropertyName { get; set; }
public Type PropertyType { get; set; }
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>
/// A string that represents the current object.
/// </returns>
/// <filterpriority>2</filterpriority>
public override string ToString() {
return string.Format("Index: {0}, ColumnLabel: {1}, DataField: {2}", this.Index, this.ColumnLabel, this.DataField);
}
}
My app wants nice short ToStrings() for various reasons, but the DefaultValueFormatter or a CustomValueFormatter helps me see whats wrong with my tests quickly.