Dreamine.UI.WinForms.Tests 1.0.0.0
Dreamine.UI.WinForms.Tests 기능을 검증하는 자동화 테스트 프로젝트입니다.
로딩중...
검색중...
일치하는것 없음
DreamineDrawHelperTests.cs
이 파일의 문서화 페이지로 가기
1using System.Drawing;
2using System.Drawing.Drawing2D;
4using Xunit;
5
7
17{
26 [Fact]
28 {
29 var path = DreamineDrawHelper.RoundedRect(new Rectangle(0, 0, 100, 50), 8f);
30 Assert.NotNull(path);
31 // Closed path has at least one figure
32 path.Dispose();
33 }
34
43 [Fact]
45 {
46 var rect = new RectangleF(0, 0, 100, 50);
47 using var path = DreamineDrawHelper.RoundedRect(rect, 0f);
48 Assert.NotNull(path);
49 }
50
83 [Theory]
84 [InlineData(100, 150, 200)]
85 [InlineData(0, 0, 0 )]
86 [InlineData(255, 0, 128)]
87 public void Blend_WithZeroAlpha_ReturnsBaseColor(int r, int g, int b)
88 {
89 var baseColor = Color.FromArgb(255, r, g, b);
90 var result = DreamineDrawHelper.Blend(baseColor, Color.White, 0f);
91 Assert.Equal(baseColor.R, result.R);
92 Assert.Equal(baseColor.G, result.G);
93 Assert.Equal(baseColor.B, result.B);
94 }
95
104 [Fact]
106 {
107 var result = DreamineDrawHelper.Blend(Color.Black, Color.White, 1f);
108 Assert.Equal(255, result.R);
109 Assert.Equal(255, result.G);
110 Assert.Equal(255, result.B);
111 }
112
121 [Fact]
123 {
124 var result = DreamineDrawHelper.Blend(Color.FromArgb(255, 0, 0, 0),
125 Color.FromArgb(255, 100, 100, 100), 0.5f);
126 Assert.InRange(result.R, 48, 52); // 50 ± rounding
127 }
128
145 [Theory]
146 [InlineData(0)]
147 [InlineData(128)]
148 [InlineData(255)]
149 public void Blend_ResultChannels_AlwaysInRange(int channel)
150 {
151 var result = DreamineDrawHelper.Blend(
152 Color.FromArgb(255, channel, channel, channel),
153 Color.White, 0.5f);
154 Assert.InRange(result.R, 0, 255);
155 Assert.InRange(result.G, 0, 255);
156 Assert.InRange(result.B, 0, 255);
157 }
158
167 [Fact]
169 {
170 using var bmp = new Bitmap(100, 50);
171 using var g = Graphics.FromImage(bmp);
172 using var brush = new SolidBrush(Color.Navy);
173 using var pen = new Pen(Color.White);
174 var ex = Record.Exception(() =>
175 DreamineDrawHelper.FillRoundedRect(g, brush, pen, new Rectangle(5, 5, 90, 40), 6f));
176 Assert.Null(ex);
177 }
178
187 [Fact]
189 {
190 using var bmp = new Bitmap(1, 1);
191 using var g = Graphics.FromImage(bmp);
192 var ex = Record.Exception(() =>
193 DreamineDrawHelper.FillRoundedGradient(g, Color.Black, Color.White, null,
194 new Rectangle(0, 0, 0, 0), 6f));
195 Assert.Null(ex);
196 }
197}