MarginTests.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. View.Diagnostics = ViewDiagnosticFlags.Thickness;
  11. var view = new View { Height = 3, Width = 3 };
  12. view.Margin.Thickness = new (1);
  13. var superView = new View ();
  14. superView.ColorScheme = new()
  15. {
  16. Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
  17. };
  18. superView.Add (view);
  19. Assert.Equal (ColorName16.Red, view.Margin.GetNormalColor ().Foreground.GetClosestNamedColor16 ());
  20. Assert.Equal (ColorName16.Red, superView.GetNormalColor ().Foreground.GetClosestNamedColor16 ());
  21. Assert.Equal (superView.GetNormalColor (), view.Margin.GetNormalColor ());
  22. Assert.Equal (superView.GetFocusColor (), view.Margin.GetFocusColor ());
  23. superView.BeginInit ();
  24. superView.EndInit ();
  25. view.SetNeedsDraw();
  26. view.Draw ();
  27. View.Diagnostics = ViewDiagnosticFlags.Off;
  28. TestHelpers.AssertDriverContentsAre (
  29. @"
  30. MMM
  31. M M
  32. MMM",
  33. output
  34. );
  35. TestHelpers.AssertDriverAttributesAre ("0", output, null, superView.GetNormalColor ());
  36. }
  37. }