MarginTests.cs 1.4 KB

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