AdornmentTests.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using UnitTests;
  2. using Xunit.Abstractions;
  3. namespace Terminal.Gui.ViewTests;
  4. public class AdornmentTests (ITestOutputHelper output)
  5. {
  6. [Fact]
  7. [SetupFakeDriver]
  8. public void Border_Is_Cleared_After_Margin_Thickness_Change ()
  9. {
  10. View view = new () { Text = "View", Width = 6, Height = 3, BorderStyle = LineStyle.Rounded };
  11. // Remove border bottom thickness
  12. view.Border!.Thickness = new (1, 1, 1, 0);
  13. // Add margin bottom thickness
  14. view.Margin!.Thickness = new (0, 0, 0, 1);
  15. Assert.Equal (6, view.Width);
  16. Assert.Equal (3, view.Height);
  17. view.Draw ();
  18. DriverAssert.AssertDriverContentsWithFrameAre (
  19. @"
  20. ╭────╮
  21. │View│
  22. ",
  23. output
  24. );
  25. // Add border bottom thickness
  26. view.Border!.Thickness = new (1, 1, 1, 1);
  27. // Remove margin bottom thickness
  28. view.Margin!.Thickness = new (0, 0, 0, 0);
  29. view.Draw ();
  30. Assert.Equal (6, view.Width);
  31. Assert.Equal (3, view.Height);
  32. DriverAssert.AssertDriverContentsWithFrameAre (
  33. @"
  34. ╭────╮
  35. │View│
  36. ╰────╯
  37. ",
  38. output
  39. );
  40. // Remove border bottom thickness
  41. view.Border!.Thickness = new (1, 1, 1, 0);
  42. // Add margin bottom thickness
  43. view.Margin!.Thickness = new (0, 0, 0, 1);
  44. Assert.Equal (6, view.Width);
  45. Assert.Equal (3, view.Height);
  46. View.SetClipToScreen ();
  47. view.Draw ();
  48. DriverAssert.AssertDriverContentsWithFrameAre (
  49. @"
  50. ╭────╮
  51. │View│
  52. ",
  53. output
  54. );
  55. }
  56. }