MarginTests.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Xunit.Abstractions;
  2. namespace Terminal.Gui.ViewTests;
  3. public class MarginTests (ITestOutputHelper output)
  4. {
  5. [Fact]
  6. [SetupFakeDriver]
  7. public void Margin_Uses_SuperView_ColorScheme ()
  8. {
  9. ((FakeDriver)Application.Driver!).SetBufferSize (5, 5);
  10. var view = new View { Height = 3, Width = 3 };
  11. view.Margin.Thickness = new (1);
  12. var superView = new View ();
  13. superView.ColorScheme = new()
  14. {
  15. Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
  16. };
  17. superView.Add (view);
  18. Assert.Equal (ColorName.Red, view.Margin.GetNormalColor ().Foreground.GetClosestNamedColor ());
  19. Assert.Equal (ColorName.Red, superView.GetNormalColor ().Foreground.GetClosestNamedColor ());
  20. Assert.Equal (superView.GetNormalColor (), view.Margin.GetNormalColor ());
  21. Assert.Equal (superView.GetFocusColor (), view.Margin.GetFocusColor ());
  22. superView.BeginInit ();
  23. superView.EndInit ();
  24. View.Diagnostics = ViewDiagnosticFlags.Padding;
  25. view.Draw ();
  26. View.Diagnostics = ViewDiagnosticFlags.Off;
  27. TestHelpers.AssertDriverContentsAre (
  28. @"
  29. MMM
  30. M M
  31. MMM",
  32. output
  33. );
  34. TestHelpers.AssertDriverAttributesAre ("0", null, superView.GetNormalColor ());
  35. }
  36. }