Exemplo n.º 1
0
        public void ToolStripRenderer_DrawArrow_Invoke_CallsRenderArrow(ToolStripItem toolStripItem, Rectangle arrowRectangle, Color arrowColor, ArrowDirection arrowDirection)
        {
            using var image         = new Bitmap(10, 10);
            using Graphics graphics = Graphics.FromImage(image);
            var eventArgs = new ToolStripArrowRenderEventArgs(graphics, toolStripItem, arrowRectangle, arrowColor, arrowDirection);

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

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

            // Remove handler.
            renderer.RenderArrow -= handler;
            renderer.DrawArrow(eventArgs);
            Assert.Equal(1, callCount);
        }
Exemplo n.º 2
0
        public void ToolStripRenderer_DrawArrow_NullE_ThrowsArgumentNullException()
        {
            var renderer = new SubToolStripRenderer();

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