MarginTests.cs 1.6 KB

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