2
0

MarginTests.cs 1.4 KB

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