public void DrawFocus_InvalidRowIndex_ThrowsInvalidOperationException(int rowIndex) { using (var image = new Bitmap(10, 10)) using (Graphics graphics = Graphics.FromImage(image)) { var dataGridView = new DataGridView(); dataGridView.Columns.Add("name", "text"); var e = new DataGridViewRowPrePaintEventArgs(dataGridView, graphics, Rectangle.Empty, Rectangle.Empty, rowIndex, DataGridViewElementStates.Displayed, null, new DataGridViewCellStyle(), false, false); Assert.Throws <InvalidOperationException>(() => e.DrawFocus(new Rectangle(1, 2, 3, 4), true)); } }
public void DrawFocus_ValidRowIndex_Success() { using (var image = new Bitmap(10, 10)) using (Graphics graphics = Graphics.FromImage(image)) { var dataGridView = new DataGridView(); dataGridView.Columns.Add("name", "text"); var e = new DataGridViewRowPrePaintEventArgs(dataGridView, graphics, Rectangle.Empty, Rectangle.Empty, 0, DataGridViewElementStates.Displayed, null, new DataGridViewCellStyle(), false, false); e.DrawFocus(new Rectangle(1, 2, 3, 4), true); } }