SplitContainerTests.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using Terminal.Gui;
  3. using Xunit;
  4. using Xunit.Abstractions;
  5. namespace UnitTests {
  6. public class SplitContainerTests {
  7. readonly ITestOutputHelper output;
  8. public SplitContainerTests (ITestOutputHelper output)
  9. {
  10. this.output = output;
  11. }
  12. [Fact,AutoInitShutdown]
  13. public void TestSplitContainer_Vertical()
  14. {
  15. var splitContainer = Get11By3SplitContainer ();
  16. splitContainer.Redraw (splitContainer.Bounds);
  17. string looksLike =
  18. @"
  19. 11111│22222
  20. │ ";
  21. TestHelpers.AssertDriverContentsAre (looksLike, output);
  22. }
  23. [Fact, AutoInitShutdown]
  24. public void TestSplitContainer_Vertical_Focused ()
  25. {
  26. var splitContainer = Get11By3SplitContainer ();
  27. splitContainer.EnsureFocus ();
  28. splitContainer.FocusFirst ();
  29. splitContainer.Redraw (splitContainer.Bounds);
  30. string looksLike =
  31. @"
  32. 11111│22222
  33. │ ";
  34. TestHelpers.AssertDriverContentsAre (looksLike, output);
  35. }
  36. [Fact, AutoInitShutdown]
  37. public void TestSplitContainer_Horizontal ()
  38. {
  39. var splitContainer = Get11By3SplitContainer ();
  40. splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
  41. splitContainer.Redraw (splitContainer.Bounds);
  42. string looksLike =
  43. @"
  44. 11111111111
  45. ───────────
  46. 22222222222";
  47. TestHelpers.AssertDriverContentsAre (looksLike, output);
  48. }
  49. [Fact, AutoInitShutdown]
  50. public void TestSplitContainer_Horizontal_Focused ()
  51. {
  52. var splitContainer = Get11By3SplitContainer ();
  53. splitContainer.Orientation = Terminal.Gui.Graphs.Orientation.Horizontal;
  54. splitContainer.EnsureFocus();
  55. splitContainer.FocusFirst();
  56. splitContainer.Redraw (splitContainer.Bounds);
  57. string looksLike =
  58. @"
  59. 11111111111
  60. ─────◊─────
  61. 22222222222";
  62. TestHelpers.AssertDriverContentsAre (looksLike, output);
  63. }
  64. private SplitContainer Get11By3SplitContainer ()
  65. {
  66. var container = new SplitContainer () {
  67. Width = 11,
  68. Height = 3,
  69. };
  70. container.Panel1.Add (new Label (new string ('1', 100)));
  71. container.Panel2.Add (new Label (new string ('2', 100)));
  72. Application.Top.Add (container);
  73. container.ColorScheme = new ColorScheme ();
  74. container.LayoutSubviews ();
  75. return container;
  76. }
  77. }
  78. }