Skip to content

Commit 7b30da6

Browse files
v-chaowendyv-chaowendy
v-chaowendy
authored and
v-chaowendy
committed
null&false
1 parent ed86bcc commit 7b30da6

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/FocusableLabelTests.cs

+35-2
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,53 @@
33

44
#nullable enable
55

6+
using System.Reflection;
7+
68
namespace System.Windows.Forms;
79

810
public class FocusableLabelTests
911
{
1012
[Fact]
11-
public void UnderlineWhenFocused_DefaultValue_ShouldBeTrue()
13+
public void UnderlineWhenFocused_ShouldBeTrue()
1214
{
1315
using FocusableLabel label = new();
1416

1517
label.UnderlineWhenFocused.Should().BeTrue();
1618
}
1719

1820
[Fact]
19-
public void FocusableLabel_ShouldBeSelectableAndTabStop()
21+
public void UnderlineWhenFocused_SetToFalse_ShouldBeFalse()
22+
{
23+
using FocusableLabel label = new();
24+
25+
label.UnderlineWhenFocused = false;
26+
27+
label.UnderlineWhenFocused.Should().BeFalse();
28+
}
29+
30+
[Fact]
31+
public void CreateParams_ClassName_ShouldBeNull()
32+
{
33+
using FocusableLabel label = new();
34+
35+
var createParams = GetCreateParams(label);
36+
37+
createParams.Should().NotBeNull();
38+
39+
var className = createParams?.GetType().GetProperty("ClassName")?.GetValue(createParams);
40+
41+
className.Should().BeNull();
42+
}
43+
44+
private static object? GetCreateParams(Control control)
45+
{
46+
return typeof(Control)
47+
.GetProperty("CreateParams", BindingFlags.NonPublic | BindingFlags.Instance)?
48+
.GetValue(control);
49+
}
50+
51+
[Fact]
52+
public void TabStop_ShouldBeTrue()
2053
{
2154
using FocusableLabel label = new();
2255

0 commit comments

Comments
 (0)