AdornmentTests.cs 2.1 KB

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