Since obviously there is a lot to be done to set up the DataGridViewCell
's and DataGridView
's, why don't you try something else?
First, create a component that does your special formatting:
public class SpecialFormatter
{
public object Format(object value)
{
var formattedValue = string.Empty;
// ... logic to test here
return FormattedValue;
}
}
And then use it your DataGridViewCell
implementation:
public class MyCell : DataGridViewCell
{
protected override object GetFormattedValue(object value, int rowIndex, ref System.Windows.Forms.DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, System.Windows.Forms.DataGridViewDataErrorContexts context)
{
return MyCustomFormatting(value);
}
private object MyCustomFormatting(object value)
{
return new SpecialFormatter.Format(value);
}
}
Then you go ahead and unit test SpecialFormatter
and you're done. Unless there is much else going on in your DataGridViewCell
implementation, then there is not much value in testing it.