2
0

FrameViewTests.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Xunit.Abstractions;
  2. namespace Terminal.Gui.ViewsTests;
  3. public class FrameViewTests (ITestOutputHelper output)
  4. {
  5. [Fact]
  6. public void Constructors_Defaults ()
  7. {
  8. var fv = new FrameView ();
  9. Assert.Equal (string.Empty, fv.Title);
  10. Assert.Equal (string.Empty, fv.Text);
  11. Assert.Equal (LineStyle.Single, fv.BorderStyle);
  12. fv = new() { Title = "Test" };
  13. Assert.Equal ("Test", fv.Title);
  14. Assert.Equal (string.Empty, fv.Text);
  15. Assert.Equal (LineStyle.Single, fv.BorderStyle);
  16. fv = new()
  17. {
  18. X = 1,
  19. Y = 2,
  20. Width = 10,
  21. Height = 20,
  22. Title = "Test"
  23. };
  24. Assert.Equal ("Test", fv.Title);
  25. Assert.Equal (string.Empty, fv.Text);
  26. fv.BeginInit ();
  27. fv.EndInit ();
  28. Assert.Equal (LineStyle.Single, fv.BorderStyle);
  29. Assert.Equal (new (1, 2, 10, 20), fv.Frame);
  30. }
  31. [Fact]
  32. [AutoInitShutdown]
  33. public void Draw_Defaults ()
  34. {
  35. ((FakeDriver)Application.Driver!).SetBufferSize (10, 10);
  36. var fv = new FrameView ();
  37. Assert.Equal (string.Empty, fv.Title);
  38. Assert.Equal (string.Empty, fv.Text);
  39. var top = new Toplevel ();
  40. top.Add (fv);
  41. Application.Begin (top);
  42. Assert.Equal (new (0, 0, 0, 0), fv.Frame);
  43. TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
  44. fv.Height = 5;
  45. fv.Width = 5;
  46. Assert.Equal (new (0, 0, 5, 5), fv.Frame);
  47. Application.Refresh ();
  48. TestHelpers.AssertDriverContentsWithFrameAre (
  49. @"
  50. ┌───┐
  51. │ │
  52. │ │
  53. │ │
  54. └───┘",
  55. output
  56. );
  57. fv.X = 1;
  58. fv.Y = 2;
  59. Assert.Equal (new (1, 2, 5, 5), fv.Frame);
  60. Application.Refresh ();
  61. TestHelpers.AssertDriverContentsWithFrameAre (
  62. @"
  63. ┌───┐
  64. │ │
  65. │ │
  66. │ │
  67. └───┘",
  68. output
  69. );
  70. fv.X = -1;
  71. fv.Y = -2;
  72. Assert.Equal (new (-1, -2, 5, 5), fv.Frame);
  73. Application.Refresh ();
  74. TestHelpers.AssertDriverContentsWithFrameAre (
  75. @"
  76. ───┘",
  77. output
  78. );
  79. fv.X = 7;
  80. fv.Y = 8;
  81. Assert.Equal (new (7, 8, 5, 5), fv.Frame);
  82. Application.Refresh ();
  83. TestHelpers.AssertDriverContentsWithFrameAre (
  84. @"
  85. ┌──
  86. │ ",
  87. output
  88. );
  89. top.Dispose ();
  90. }
  91. }