Dreamine.UI.WinForms.Tests
1.0.0.0
Dreamine.UI.WinForms.Tests 기능을 검증하는 자동화 테스트 프로젝트입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
DreamineRadioButtonTests.cs
이 파일의 문서화 페이지로 가기
1
using
System.Runtime.ExceptionServices;
2
using
System.Windows.Forms;
3
using
Dreamine.UI.WinForms.Controls;
4
using
Xunit;
5
6
namespace
Dreamine.UI.WinForms.Tests.Controls
;
7
16
public
class
DreamineRadioButtonTests
17
{
34
private
static
void
Sta
(Action action)
35
{
36
Exception?
ex
=
null
;
37
var t =
new
Thread(() => {
try
{ action(); }
catch
(Exception e) {
ex
= e; } });
38
t.SetApartmentState(ApartmentState.STA);
39
t.Start();
40
t.Join();
41
if
(
ex
is not
null
) ExceptionDispatchInfo.Capture(
ex
).Throw();
42
}
43
52
[Fact]
53
public
void
IsChecked_DefaultIsFalse
()
54
=>
Sta
(() =>
55
{
56
var rb =
new
DreamineRadioButton();
57
Assert.False(rb.IsChecked);
58
});
59
68
[Fact]
69
public
void
IsChecked_SetToTrue_PropertyChanges
()
70
=>
Sta
(() =>
71
{
72
var rb =
new
DreamineRadioButton {
IsChecked
=
true
};
73
Assert.True(rb.IsChecked);
74
});
75
84
[Fact]
85
public
void
IsChecked_SetTrue_RaisesCheckedChanged
()
86
=>
Sta
(() =>
87
{
88
var rb =
new
DreamineRadioButton();
89
int
fired
= 0;
90
rb.CheckedChanged += (_, _) =>
fired
++;
91
rb.IsChecked =
true
;
92
Assert.Equal(1,
fired
);
93
});
94
103
[Fact]
104
public
void
GroupName_DefaultIsEmpty
()
105
=>
Sta
(() =>
106
{
107
var rb =
new
DreamineRadioButton();
108
Assert.Equal(
string
.Empty, rb.GroupName);
109
});
110
119
[Fact]
120
public
void
GroupName_SetAndGet_Roundtrip
()
121
=>
Sta
(() =>
122
{
123
var rb =
new
DreamineRadioButton { GroupName =
"group1"
};
124
Assert.Equal(
"group1"
, rb.GroupName);
125
});
126
135
[Fact]
136
public
void
SameGroup_SelectingOne_UnchecksOther
()
137
=>
Sta
(() =>
138
{
139
using
var container =
new
Panel();
140
var
rb1
=
new
DreamineRadioButton { GroupName =
"g"
,
IsChecked
=
true
};
141
var
rb2
=
new
DreamineRadioButton { GroupName =
"g"
};
142
container.Controls.Add(
rb1
);
143
container.Controls.Add(
rb2
);
144
rb2.IsChecked =
true
;
145
Assert.False(
rb1
.IsChecked);
146
Assert.True(
rb2
.IsChecked);
147
});
148
157
[Fact]
158
public
void
DifferentGroups_SelectingOne_DoesNotAffectOther
()
159
=>
Sta
(() =>
160
{
161
using
var container =
new
Panel();
162
var
rb1
=
new
DreamineRadioButton { GroupName =
"g1"
,
IsChecked
=
true
};
163
var
rb2
=
new
DreamineRadioButton { GroupName =
"g2"
};
164
container.Controls.Add(
rb1
);
165
container.Controls.Add(
rb2
);
166
rb2.IsChecked =
true
;
167
Assert.True(
rb1
.IsChecked);
168
Assert.True(
rb2
.IsChecked);
169
});
170
179
[Fact]
180
public
void
NoParent_SettingChecked_DoesNotThrow
()
181
=>
Sta
(() =>
182
{
183
var rb =
new
DreamineRadioButton();
184
var
ex
= Record.Exception(() => rb.IsChecked =
true
);
185
Assert.Null(
ex
);
186
});
187
}
Dreamine.UI.WinForms.Tests.Controls
Definition
DreamineButtonTests.cs:6
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests
Definition
DreamineRadioButtonTests.cs:17
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.IsChecked_SetToTrue_PropertyChanges
void IsChecked_SetToTrue_PropertyChanges()
Definition
DreamineRadioButtonTests.cs:69
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.IsChecked
rb. IsChecked
Definition
DreamineRadioButtonTests.cs:91
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.NoParent_SettingChecked_DoesNotThrow
void NoParent_SettingChecked_DoesNotThrow()
Definition
DreamineRadioButtonTests.cs:180
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.GroupName_DefaultIsEmpty
void GroupName_DefaultIsEmpty()
Definition
DreamineRadioButtonTests.cs:104
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.SameGroup_SelectingOne_UnchecksOther
void SameGroup_SelectingOne_UnchecksOther()
Definition
DreamineRadioButtonTests.cs:136
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.Sta
static void Sta(Action action)
Definition
DreamineRadioButtonTests.cs:34
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.rb1
var rb1
Definition
DreamineRadioButtonTests.cs:140
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.ex
var ex
Definition
DreamineRadioButtonTests.cs:184
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.GroupName_SetAndGet_Roundtrip
void GroupName_SetAndGet_Roundtrip()
Definition
DreamineRadioButtonTests.cs:120
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.IsChecked_SetTrue_RaisesCheckedChanged
void IsChecked_SetTrue_RaisesCheckedChanged()
Definition
DreamineRadioButtonTests.cs:85
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.fired
int fired
Definition
DreamineRadioButtonTests.cs:89
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.rb2
var rb2
Definition
DreamineRadioButtonTests.cs:141
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.IsChecked_DefaultIsFalse
void IsChecked_DefaultIsFalse()
Definition
DreamineRadioButtonTests.cs:53
Dreamine.UI.WinForms.Tests.Controls.DreamineRadioButtonTests.DifferentGroups_SelectingOne_DoesNotAffectOther
void DifferentGroups_SelectingOne_DoesNotAffectOther()
Definition
DreamineRadioButtonTests.cs:158
Controls
DreamineRadioButtonTests.cs
다음에 의해 생성됨 :
1.17.0