With.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Terminal.Gui;
  2. namespace TerminalGuiFluentTesting;
  3. /// <summary>
  4. /// Entry point to fluent assertions.
  5. /// </summary>
  6. public static class With
  7. {
  8. /// <summary>
  9. /// Entrypoint to fluent assertions
  10. /// </summary>
  11. /// <param name="width"></param>
  12. /// <param name="height"></param>
  13. /// <param name="v2TestDriver">Which v2 v2TestDriver to use for the test</param>
  14. /// <returns></returns>
  15. public static GuiTestContext A<T> (int width, int height, V2TestDriver v2TestDriver) where T : Toplevel, new ()
  16. {
  17. return new (() => new T (), width, height,v2TestDriver);
  18. }
  19. /// <summary>
  20. /// Overload that takes an existing instance <paramref name="toplevel"/>
  21. /// instead of creating one.
  22. /// </summary>
  23. /// <param name="toplevel"></param>
  24. /// <param name="width"></param>
  25. /// <param name="height"></param>
  26. /// <param name="v2TestDriver"></param>
  27. /// <returns></returns>
  28. public static GuiTestContext A (Toplevel toplevel, int width, int height, V2TestDriver v2TestDriver)
  29. {
  30. return new (()=>toplevel, width, height, v2TestDriver);
  31. }
  32. /// <summary>
  33. /// The global timeout to allow for any given application to run for before shutting down.
  34. /// </summary>
  35. public static TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds (30);
  36. }