public void CheckedListBox_OnDrawItem_InvokeWithHandle_Success(Font font, Rectangle rect, int index, DrawItemState state, Color foreColor, Color backColor) { using var control = new SubCheckedListBox(); control.Items.Add("item1"); control.Items.Add("item2"); Assert.NotEqual(IntPtr.Zero, control.Handle); int invalidatedCallCount = 0; control.Invalidated += (sender, e) => invalidatedCallCount++; int styleChangedCallCount = 0; control.StyleChanged += (sender, e) => styleChangedCallCount++; int createdCallCount = 0; control.HandleCreated += (sender, e) => createdCallCount++; using var image = new Bitmap(10, 10); using Graphics graphics = Graphics.FromImage(image); var e = new DrawItemEventArgs(graphics, font, rect, index, state, foreColor, backColor); control.OnDrawItem(e); Assert.True(control.IsHandleCreated); Assert.Equal(0, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); }
public void CheckedListBox_OnDrawItem_LargeEIndexEmpty_Success() { using var control = new SubCheckedListBox(); using var image = new Bitmap(10, 10); using Graphics graphics = Graphics.FromImage(image); var e = new DrawItemEventArgs(graphics, null, new Rectangle(1, 2, 3, 4), 1, DrawItemState.Default); control.OnDrawItem(e); Assert.True(control.IsHandleCreated); }
public void CheckedListBox_OnDrawItem_Invoke_Success(Font font, Rectangle rect, int index, DrawItemState state, Color foreColor, Color backColor) { using var control = new SubCheckedListBox(); control.Items.Add("item1"); control.Items.Add("item2"); using var image = new Bitmap(10, 10); using Graphics graphics = Graphics.FromImage(image); var e = new DrawItemEventArgs(graphics, font, rect, index, state, foreColor, backColor); control.OnDrawItem(e); Assert.False(control.IsHandleCreated); }
public void CheckedListBox_OnDrawItem_NullE_ThrowsNullReferenceException() { using var control = new SubCheckedListBox(); Assert.Throws <NullReferenceException>(() => control.OnDrawItem(null)); }