AllViewsDrawTests.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Xunit.Abstractions;
  2. namespace Terminal.Gui.LayoutTests;
  3. public class AllViewsDrawTests (ITestOutputHelper _output) : TestsAllViews
  4. {
  5. [Theory]
  6. [MemberData (nameof (AllViewTypes))]
  7. public void AllViews_Does_Not_Layout (Type viewType)
  8. {
  9. var view = (View)CreateInstanceIfNotGeneric (viewType);
  10. if (view == null)
  11. {
  12. _output.WriteLine ($"Ignoring {viewType} - It's a Generic");
  13. return;
  14. }
  15. if (view is IDesignable designable)
  16. {
  17. designable.EnableForDesign ();
  18. }
  19. var drawContentCount = 0;
  20. view.DrawContent += (s, e) => drawContentCount++;
  21. var layoutStartedCount = 0;
  22. view.LayoutStarted += (s, e) => layoutStartedCount++;
  23. var layoutCompleteCount = 0;
  24. view.LayoutComplete += (s, e) => layoutCompleteCount++;
  25. view.SetLayoutNeeded ();
  26. view.Layout ();
  27. Assert.Equal (0, drawContentCount);
  28. Assert.Equal (1, layoutStartedCount);
  29. Assert.Equal (1, layoutCompleteCount);
  30. view.Draw ();
  31. Assert.Equal (1, drawContentCount);
  32. Assert.Equal (1, layoutStartedCount);
  33. Assert.Equal (1, layoutCompleteCount);
  34. }
  35. }