Skip to content

Commit dd6c6a7

Browse files
committed
FixedCM issues
1 parent fd31f49 commit dd6c6a7

File tree

2 files changed

+87
-58
lines changed

2 files changed

+87
-58
lines changed

Tests/UnitTests/Dialogs/DialogTests.cs

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ public DialogTests (ITestOutputHelper output)
1414
View.DebugIDisposable = true;
1515
#endif
1616
_output = output;
17+
18+
// Override CM
19+
ConfigurationManager.RuntimeConfig = """
20+
{
21+
"Themes": [
22+
{
23+
"Default": {
24+
"Dialog.DefaultButtonAlignment" : "Center",
25+
"Dialog.DefaultBorderStyle" : "Single",
26+
"Dialog.DefaultShadow" : "None",
27+
"Button.DefaultShadow" : "None"
28+
}
29+
}
30+
]
31+
}
32+
""";
33+
ConfigurationManager.Locations = ConfigLocations.Runtime;
34+
ConfigurationManager.Load ();
1735
}
1836

1937
[Fact]
@@ -34,12 +52,6 @@ public void Add_Button_Works ()
3452
int width = $@"{Glyphs.VLine} {btn1} {btn2} {Glyphs.VLine}".Length;
3553
d.SetBufferSize (width, 1);
3654

37-
// Override CM
38-
Dialog.DefaultButtonAlignment = Alignment.Center;
39-
Dialog.DefaultBorderStyle = LineStyle.Single;
40-
Dialog.DefaultShadow = ShadowStyle.None;
41-
Button.DefaultShadow = ShadowStyle.None;
42-
4355
// Default (center)
4456
var dlg = new Dialog
4557
{
@@ -914,13 +926,6 @@ public void Dialog_In_Window_With_Size_One_Button_Aligns ()
914926
{
915927
((FakeDriver)Driver).SetBufferSize (20, 5);
916928

917-
// Override CM
918-
Window.DefaultBorderStyle = LineStyle.Single;
919-
Dialog.DefaultButtonAlignment = Alignment.Center;
920-
Dialog.DefaultBorderStyle = LineStyle.Single;
921-
Dialog.DefaultShadow = ShadowStyle.None;
922-
Button.DefaultShadow = ShadowStyle.None;
923-
924929
var win = new Window ();
925930

926931
var iterations = 0;
@@ -1021,13 +1026,7 @@ public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height, string
10211026
var win = new Window ();
10221027

10231028
int iterations = -1;
1024-
1025-
// Override CM
1026-
Dialog.DefaultButtonAlignment = Alignment.Center;
1027-
Dialog.DefaultBorderStyle = LineStyle.Single;
1028-
Dialog.DefaultShadow = ShadowStyle.None;
1029-
Button.DefaultShadow = ShadowStyle.None;
1030-
1029+
10311030
Iteration += (s, a) =>
10321031
{
10331032
iterations++;
@@ -1065,13 +1064,7 @@ public void Dialog_In_Window_Without_Size_One_Button_Aligns (int height, string
10651064
public void Dialog_Opened_From_Another_Dialog ()
10661065
{
10671066
((FakeDriver)Driver).SetBufferSize (30, 10);
1068-
1069-
// Override CM
1070-
Dialog.DefaultButtonAlignment = Alignment.Center;
1071-
Dialog.DefaultBorderStyle = LineStyle.Single;
1072-
Dialog.DefaultShadow = ShadowStyle.None;
1073-
Button.DefaultShadow = ShadowStyle.None;
1074-
1067+
10751068
var btn1 = new Button { Text = "press me 1" };
10761069
Button btn2 = null;
10771070
Button btn3 = null;
@@ -1233,12 +1226,6 @@ public void Location_Not_Default ()
12331226
[AutoInitShutdown]
12341227
public void Location_When_Application_Top_Not_Default ()
12351228
{
1236-
// Override CM
1237-
Window.DefaultBorderStyle = LineStyle.Single;
1238-
Dialog.DefaultButtonAlignment = Alignment.Center;
1239-
Dialog.DefaultBorderStyle = LineStyle.Single;
1240-
Dialog.DefaultShadow = ShadowStyle.None;
1241-
Button.DefaultShadow = ShadowStyle.None;
12421229

12431230
var expected = 5;
12441231
var d = new Dialog { X = expected, Y = expected, Height = 5, Width = 5 };
@@ -1268,8 +1255,6 @@ public void One_Button_Works ()
12681255

12691256
var d = (FakeDriver)Driver;
12701257

1271-
Button.DefaultShadow = ShadowStyle.None;
1272-
12731258
var title = "";
12741259
var btnText = "ok";
12751260

@@ -1312,8 +1297,6 @@ public void Size_Default ()
13121297
[AutoInitShutdown]
13131298
public void Size_Not_Default ()
13141299
{
1315-
Dialog.DefaultShadow = ShadowStyle.None;
1316-
Button.DefaultShadow = ShadowStyle.None;
13171300
var d = new Dialog { Width = 50, Height = 50 };
13181301

13191302
Begin (d);
@@ -1325,7 +1308,7 @@ public void Size_Not_Default ()
13251308
}
13261309

13271310
[Fact]
1328-
[SetupFakeDriver]
1311+
[AutoInitShutdown]
13291312
public void Zero_Buttons_Works ()
13301313
{
13311314
RunState runstate = null;
@@ -1353,11 +1336,6 @@ public void Zero_Buttons_Works ()
13531336
params Button [] btns
13541337
)
13551338
{
1356-
// Override CM
1357-
Dialog.DefaultButtonAlignment = Alignment.Center;
1358-
Dialog.DefaultBorderStyle = LineStyle.Single;
1359-
Dialog.DefaultShadow = ShadowStyle.None;
1360-
Button.DefaultShadow = ShadowStyle.None;
13611339

13621340
var dlg = new Dialog
13631341
{

Tests/UnitTests/Dialogs/MessageBoxTests.cs

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,23 @@ public void Location_And_Size_Correct (string message, bool wrapMessage, bool ha
156156
int iterations = -1;
157157

158158
((FakeDriver)Application.Driver!).SetBufferSize (15, 15); // 15 x 15 gives us enough room for a button with one char (9x1)
159-
Dialog.DefaultShadow = ShadowStyle.None;
160-
Button.DefaultShadow = ShadowStyle.None;
159+
160+
161+
// Override CM
162+
ConfigurationManager.RuntimeConfig = """
163+
{
164+
"Themes": [
165+
{
166+
"Default": {
167+
"Dialog.DefaultShadow": "None",
168+
"Button.DefaultShadow": "None"
169+
}
170+
}
171+
]
172+
}
173+
""";
174+
ConfigurationManager.Locations = ConfigLocations.Runtime;
175+
ConfigurationManager.Load ();
161176

162177
var mbFrame = Rectangle.Empty;
163178

@@ -195,10 +210,22 @@ public void Message_With_Spaces_WrapMessage_False ()
195210
$"{Glyphs.LeftBracket}{Glyphs.LeftDefaultIndicator} btn {Glyphs.RightDefaultIndicator}{Glyphs.RightBracket}";
196211

197212
// Override CM
198-
MessageBox.DefaultButtonAlignment = Alignment.End;
199-
MessageBox.DefaultBorderStyle = LineStyle.Double;
200-
Dialog.DefaultShadow = ShadowStyle.None;
201-
Button.DefaultShadow = ShadowStyle.None;
213+
ConfigurationManager.RuntimeConfig = """
214+
{
215+
"Themes": [
216+
{
217+
"Default": {
218+
"Dialog.DefaultShadow": "None",
219+
"MessageBox.DefaultButtonAlignment": "End",
220+
"MessageBox.DefaultBorderStyle": "Double",
221+
"Button.DefaultShadow": "None"
222+
}
223+
}
224+
]
225+
}
226+
""";
227+
ConfigurationManager.Locations = ConfigLocations.Runtime;
228+
ConfigurationManager.Load ();
202229

203230
Application.Iteration += (s, a) =>
204231
{
@@ -267,10 +294,22 @@ public void Message_With_Spaces_WrapMessage_True ()
267294
$"{Glyphs.LeftBracket}{Glyphs.LeftDefaultIndicator} btn {Glyphs.RightDefaultIndicator}{Glyphs.RightBracket}";
268295

269296
// Override CM
270-
MessageBox.DefaultButtonAlignment = Alignment.End;
271-
MessageBox.DefaultBorderStyle = LineStyle.Double;
272-
Dialog.DefaultShadow = ShadowStyle.None;
273-
Button.DefaultShadow = ShadowStyle.None;
297+
ConfigurationManager.RuntimeConfig = """
298+
{
299+
"Themes": [
300+
{
301+
"Default": {
302+
"Dialog.DefaultShadow": "None",
303+
"MessageBox.DefaultButtonAlignment": "End",
304+
"MessageBox.DefaultBorderStyle": "Double",
305+
"Button.DefaultShadow": "None"
306+
}
307+
}
308+
]
309+
}
310+
""";
311+
ConfigurationManager.Locations = ConfigLocations.Runtime;
312+
ConfigurationManager.Load ();
274313

275314
Application.Iteration += (s, a) =>
276315
{
@@ -449,10 +488,22 @@ public void UICatalog_AboutBox ()
449488
((FakeDriver)Application.Driver).SetBufferSize (70, 15);
450489

451490
// Override CM
452-
MessageBox.DefaultButtonAlignment = Alignment.End;
453-
MessageBox.DefaultBorderStyle = LineStyle.Double;
454-
Dialog.DefaultShadow = ShadowStyle.None;
455-
Button.DefaultShadow = ShadowStyle.None;
491+
ConfigurationManager.RuntimeConfig = """
492+
{
493+
"Themes": [
494+
{
495+
"Default": {
496+
"Dialog.DefaultShadow": "None",
497+
"MessageBox.DefaultButtonAlignment": "End",
498+
"MessageBox.DefaultBorderStyle": "Double",
499+
"Button.DefaultShadow": "None"
500+
}
501+
}
502+
]
503+
}
504+
""";
505+
ConfigurationManager.Locations = ConfigLocations.Runtime;
506+
ConfigurationManager.Load ();
456507

457508
Application.Iteration += (s, a) =>
458509
{
@@ -462,7 +513,7 @@ public void UICatalog_AboutBox ()
462513
{
463514
MessageBox.Query (
464515
"",
465-
UICatalog.UICatalogTop.GetAboutBoxMessage (),
516+
UICatalogTop.GetAboutBoxMessage (),
466517
wrapMessage: false,
467518
buttons: "_Ok"
468519
);

0 commit comments

Comments
 (0)