public void PaintCellsBackground_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 DataGridViewRowPostPaintEventArgs(dataGridView, graphics, Rectangle.Empty, Rectangle.Empty, rowIndex, DataGridViewElementStates.Displayed, null, new DataGridViewCellStyle(), false, false); Assert.Throws <InvalidOperationException>(() => e.PaintCellsBackground(new Rectangle(1, 2, 3, 4), true)); } }
public void PaintCellsBackground_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 DataGridViewRowPostPaintEventArgs(dataGridView, graphics, Rectangle.Empty, Rectangle.Empty, 0, DataGridViewElementStates.Displayed, null, new DataGridViewCellStyle(), false, false); e.PaintCellsBackground(new Rectangle(1, 2, 3, 4), true); } }