PaddingTests.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using UnitTests;
  2. using Xunit.Abstractions;
  3. namespace UnitTests.ViewTests;
  4. public class PaddingTests (ITestOutputHelper output)
  5. {
  6. [Fact]
  7. [SetupFakeApplication]
  8. public void Padding_Uses_Parent_Scheme ()
  9. {
  10. ApplicationImpl.Instance.Driver!.SetScreenSize (5, 5);
  11. var view = new View
  12. {
  13. App = ApplicationImpl.Instance,
  14. Height = 3, Width = 3
  15. };
  16. view.Padding!.Thickness = new (1);
  17. view.Padding.Diagnostics = ViewDiagnosticFlags.Thickness;
  18. view.SetScheme (new()
  19. {
  20. Normal = new (Color.Red, Color.Green), Focus = new (Color.Green, Color.Red)
  21. });
  22. Assert.Equal (ColorName16.Red, view.Padding.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ());
  23. Assert.Equal (view.GetAttributeForRole (VisualRole.Normal), view.Padding.GetAttributeForRole (VisualRole.Normal));
  24. view.BeginInit ();
  25. view.EndInit ();
  26. view.Draw ();
  27. DriverAssert.AssertDriverContentsAre (
  28. @"
  29. PPP
  30. P P
  31. PPP",
  32. output
  33. );
  34. DriverAssert.AssertDriverAttributesAre ("0", output, null, view.GetAttributeForRole (VisualRole.Normal));
  35. }
  36. }