Example #1
0
        public void ToolStripRenderer_DrawItemText_Invoke_CallsRenderItemText(ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format)
        {
            using var image         = new Bitmap(10, 10);
            using Graphics graphics = Graphics.FromImage(image);
            var eventArgs = new ToolStripItemTextRenderEventArgs(graphics, item, text, textRectangle, textColor, textFont, format);

            var renderer  = new SubToolStripRenderer();
            int callCount = 0;
            ToolStripItemTextRenderEventHandler handler = (sender, e) =>
            {
                Assert.Same(renderer, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };

            // Call with handler.
            renderer.RenderItemText += handler;
            renderer.DrawItemText(eventArgs);
            Assert.Equal(1, callCount);

            // Remove handler.
            renderer.RenderItemText -= handler;
            renderer.DrawItemText(eventArgs);
            Assert.Equal(1, callCount);
        }
Example #2
0
        public void ToolStripRenderer_DrawItemText_NullE_ThrowsArgumentNullException()
        {
            var renderer = new SubToolStripRenderer();

            Assert.Throws <ArgumentNullException>("e", () => renderer.DrawItemText(null));
        }