public void PaintCellsContent_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.PaintCellsContent(new Rectangle(1, 2, 3, 4))); } }
public void PaintCellsContent_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.PaintCellsContent(new Rectangle(1, 2, 3, 4)); } }