Explorar el Código

Made unit tests more resiliant to config changes

Tig hace 1 año
padre
commit
271a73cba1
Se han modificado 2 ficheros con 42 adiciones y 1 borrados
  1. 30 1
      UnitTests/Dialogs/DialogTests.cs
  2. 12 0
      UnitTests/Dialogs/MessageBoxTests.cs

+ 30 - 1
UnitTests/Dialogs/DialogTests.cs

@@ -26,6 +26,10 @@ public class DialogTests
         int width = $@"{CM.Glyphs.VLine} {btn1} {btn2} {CM.Glyphs.VLine}".Length;
         int width = $@"{CM.Glyphs.VLine} {btn1} {btn2} {CM.Glyphs.VLine}".Length;
         d.SetBufferSize (width, 1);
         d.SetBufferSize (width, 1);
 
 
+        // Override CM
+        Dialog.DefaultButtonAlignment = Alignment.Center;
+        Dialog.DefaultBorderStyle = LineStyle.Single;
+
         // Default (center)
         // Default (center)
         var dlg = new Dialog
         var dlg = new Dialog
         {
         {
@@ -151,6 +155,7 @@ public class DialogTests
         int width = buttonRow.Length;
         int width = buttonRow.Length;
         d.SetBufferSize (buttonRow.Length, 3);
         d.SetBufferSize (buttonRow.Length, 3);
 
 
+
         // Default - Center
         // Default - Center
         (runstate, Dialog dlg) = RunButtonTestDialog (
         (runstate, Dialog dlg) = RunButtonTestDialog (
                                                     title,
                                                     title,
@@ -874,6 +879,11 @@ public class DialogTests
     {
     {
         ((FakeDriver)Driver).SetBufferSize (20, 5);
         ((FakeDriver)Driver).SetBufferSize (20, 5);
 
 
+        // Override CM
+        Window.DefaultBorderStyle = LineStyle.Single;
+        Dialog.DefaultButtonAlignment = Alignment.Center;
+        Dialog.DefaultBorderStyle = LineStyle.Single;
+
         var win = new Window ();
         var win = new Window ();
 
 
         var iterations = 0;
         var iterations = 0;
@@ -889,7 +899,6 @@ public class DialogTests
 
 
         win.Loaded += (s, a) =>
         win.Loaded += (s, a) =>
                       {
                       {
-                          Dialog.DefaultButtonAlignment = Alignment.Center;
                           var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] };
                           var dlg = new Dialog { Width = 18, Height = 3, Buttons = [new () { Text = "Ok" }] };
 
 
                           dlg.Loaded += (s, a) =>
                           dlg.Loaded += (s, a) =>
@@ -975,7 +984,10 @@ public class DialogTests
         var win = new Window ();
         var win = new Window ();
 
 
         int iterations = -1;
         int iterations = -1;
+
+        // Override CM
         Dialog.DefaultButtonAlignment = Alignment.Center;
         Dialog.DefaultButtonAlignment = Alignment.Center;
+        Dialog.DefaultBorderStyle = LineStyle.Single;
 
 
         Iteration += (s, a) =>
         Iteration += (s, a) =>
                      {
                      {
@@ -1012,7 +1024,10 @@ public class DialogTests
     public void Dialog_Opened_From_Another_Dialog ()
     public void Dialog_Opened_From_Another_Dialog ()
     {
     {
         ((FakeDriver)Driver).SetBufferSize (30, 10);
         ((FakeDriver)Driver).SetBufferSize (30, 10);
+
+        // Override CM
         Dialog.DefaultButtonAlignment = Alignment.Center;
         Dialog.DefaultButtonAlignment = Alignment.Center;
+        Dialog.DefaultBorderStyle = LineStyle.Single;
 
 
         var btn1 = new Button { Text = "press me 1" };
         var btn1 = new Button { Text = "press me 1" };
         Button btn2 = null;
         Button btn2 = null;
@@ -1159,6 +1174,11 @@ public class DialogTests
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void Location_When_Application_Top_Not_Default ()
     public void Location_When_Application_Top_Not_Default ()
     {
     {
+        // Override CM
+        Window.DefaultBorderStyle = LineStyle.Single;
+        Dialog.DefaultButtonAlignment = Alignment.Center;
+        Dialog.DefaultBorderStyle = LineStyle.Single;
+
         var expected = 5;
         var expected = 5;
         var d = new Dialog { X = expected, Y = expected, Height = 5, Width = 5 };
         var d = new Dialog { X = expected, Y = expected, Height = 5, Width = 5 };
         Begin (d);
         Begin (d);
@@ -1188,6 +1208,11 @@ public class DialogTests
 
 
         int iterations = -1;
         int iterations = -1;
 
 
+        // Override CM
+        Window.DefaultBorderStyle = LineStyle.Single;
+        Dialog.DefaultButtonAlignment = Alignment.Center;
+        Dialog.DefaultBorderStyle = LineStyle.Single;
+
         Iteration += (s, a) =>
         Iteration += (s, a) =>
                      {
                      {
                          iterations++;
                          iterations++;
@@ -1361,6 +1386,10 @@ public class DialogTests
         params Button [] btns
         params Button [] btns
     )
     )
     {
     {
+        // Override CM
+        Dialog.DefaultButtonAlignment = Alignment.Center;
+        Dialog.DefaultBorderStyle = LineStyle.Single;
+
         var dlg = new Dialog
         var dlg = new Dialog
         {
         {
             Title = title,
             Title = title,

+ 12 - 0
UnitTests/Dialogs/MessageBoxTests.cs

@@ -174,6 +174,10 @@ public class MessageBoxTests
         var btn =
         var btn =
             $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
             $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
 
 
+        // Override CM
+        MessageBox.DefaultButtonAlignment = Alignment.End;
+        MessageBox.DefaultBorderStyle = LineStyle.Double;
+
         Application.Iteration += (s, a) =>
         Application.Iteration += (s, a) =>
                                  {
                                  {
                                      iterations++;
                                      iterations++;
@@ -239,6 +243,10 @@ public class MessageBoxTests
         var btn =
         var btn =
             $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
             $"{CM.Glyphs.LeftBracket}{CM.Glyphs.LeftDefaultIndicator} btn {CM.Glyphs.RightDefaultIndicator}{CM.Glyphs.RightBracket}";
 
 
+        // Override CM
+        MessageBox.DefaultButtonAlignment = Alignment.End;
+        MessageBox.DefaultBorderStyle = LineStyle.Double;
+
         Application.Iteration += (s, a) =>
         Application.Iteration += (s, a) =>
                                  {
                                  {
                                      iterations++;
                                      iterations++;
@@ -415,6 +423,10 @@ public class MessageBoxTests
         int iterations = -1;
         int iterations = -1;
         ((FakeDriver)Application.Driver).SetBufferSize (70, 15);
         ((FakeDriver)Application.Driver).SetBufferSize (70, 15);
 
 
+        // Override CM
+        MessageBox.DefaultButtonAlignment = Alignment.End;
+        MessageBox.DefaultBorderStyle = LineStyle.Double;
+
         Application.Iteration += (s, a) =>
         Application.Iteration += (s, a) =>
                                  {
                                  {
                                      iterations++;
                                      iterations++;