|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +using System.Drawing; |
| 5 | + |
| 6 | +namespace System.Windows.Forms.Tests; |
| 7 | + |
| 8 | +public class ToolStripProfessionalLowResolutionRendererTests |
| 9 | +{ |
| 10 | + private readonly ToolStripProfessionalLowResolutionRenderer _toolStripProfessionalLowResolutionRenderer = new(); |
| 11 | + |
| 12 | + [Fact] |
| 13 | + public void Ctor_Default_Success() |
| 14 | + { |
| 15 | + _toolStripProfessionalLowResolutionRenderer.Should().NotBeNull(); |
| 16 | + _toolStripProfessionalLowResolutionRenderer.Should().BeOfType<ToolStripProfessionalLowResolutionRenderer>(); |
| 17 | + _toolStripProfessionalLowResolutionRenderer.Should().BeAssignableTo<ToolStripProfessionalRenderer>(); |
| 18 | + } |
| 19 | + |
| 20 | + [WinFormsFact] |
| 21 | + public void OnRenderToolStripBackground_DoesNotThrow_ForNonDropDown() |
| 22 | + { |
| 23 | + using ToolStrip toolStrip = new(); |
| 24 | + using Bitmap bmp = new(10, 10); |
| 25 | + using Graphics g = Graphics.FromImage(bmp); |
| 26 | + ToolStripRenderEventArgs args = new(g, toolStrip); |
| 27 | + |
| 28 | + Action action = () => _toolStripProfessionalLowResolutionRenderer.TestAccessor().Dynamic.OnRenderToolStripBackground(args); |
| 29 | + |
| 30 | + action.Should().NotThrow(); |
| 31 | + } |
| 32 | + |
| 33 | + [WinFormsFact] |
| 34 | + public void OnRenderToolStripBackground_CallsBase_ForDropDown() |
| 35 | + { |
| 36 | + using ToolStripDropDown dropDown = new(); |
| 37 | + using Bitmap bmp = new(10, 10); |
| 38 | + using Graphics g = Graphics.FromImage(bmp); |
| 39 | + ToolStripRenderEventArgs args = new(g, dropDown); |
| 40 | + |
| 41 | + Action action = () => _toolStripProfessionalLowResolutionRenderer.TestAccessor().Dynamic.OnRenderToolStripBackground(args); |
| 42 | + |
| 43 | + action.Should().NotThrow(); |
| 44 | + } |
| 45 | + |
| 46 | + [WinFormsTheory] |
| 47 | + [InlineData(typeof(MenuStrip))] |
| 48 | + [InlineData(typeof(StatusStrip))] |
| 49 | + [InlineData(typeof(ToolStripDropDown))] |
| 50 | + [InlineData(typeof(ToolStrip))] |
| 51 | + public void OnRenderToolStripBorder_DoesNotThrow_ForAllToolStrips(Type toolStripType) |
| 52 | + { |
| 53 | + using ToolStrip toolStrip = (ToolStrip)Activator.CreateInstance(toolStripType)!; |
| 54 | + using Bitmap bmp = new(10, 10); |
| 55 | + using Graphics g = Graphics.FromImage(bmp); |
| 56 | + ToolStripRenderEventArgs args = new(g, toolStrip); |
| 57 | + |
| 58 | + Action action = () => _toolStripProfessionalLowResolutionRenderer.TestAccessor().Dynamic.OnRenderToolStripBorder(args); |
| 59 | + |
| 60 | + action.Should().NotThrow(); |
| 61 | + } |
| 62 | + |
| 63 | + [Fact] |
| 64 | + public void RendererOverride_AlwaysReturnsNull() => |
| 65 | + _toolStripProfessionalLowResolutionRenderer.RendererOverride.Should().BeNull(); |
| 66 | +} |
0 commit comments