With.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 
  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="testDriver">Which v2 testDriver to use for the test</param>
  14. /// <param name="logWriter"></param>
  15. /// <returns></returns>
  16. public static GuiTestContext A<T> (int width, int height, TestDriver testDriver, TextWriter? logWriter = null) where T : Toplevel, new ()
  17. {
  18. return new (() => new T (), width, height, testDriver, logWriter, Timeout);
  19. }
  20. /// <summary>
  21. /// Overload that takes a function to create instance <paramref name="toplevelFactory"/> after application is initialized.
  22. /// </summary>
  23. /// <param name="toplevelFactory"></param>
  24. /// <param name="width"></param>
  25. /// <param name="height"></param>
  26. /// <param name="testDriver"></param>
  27. /// <returns></returns>
  28. public static GuiTestContext A (Func<Toplevel> toplevelFactory, int width, int height, TestDriver testDriver)
  29. {
  30. return new (toplevelFactory, width, height, testDriver, null, Timeout);
  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. }