With.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 ()
  19. {
  20. //Id = $"{typeof (T).Name}"
  21. }, width, height, testDriver, logWriter, Timeout);
  22. }
  23. /// <summary>
  24. /// Overload that takes a function to create instance <paramref name="toplevelFactory"/> after application is initialized.
  25. /// </summary>
  26. /// <param name="toplevelFactory"></param>
  27. /// <param name="width"></param>
  28. /// <param name="height"></param>
  29. /// <param name="testDriver"></param>
  30. /// <returns></returns>
  31. public static GuiTestContext A (Func<Toplevel> toplevelFactory, int width, int height, TestDriver testDriver)
  32. {
  33. return new (toplevelFactory, width, height, testDriver, null, Timeout);
  34. }
  35. /// <summary>
  36. /// The global timeout to allow for any given application to run for before shutting down.
  37. /// </summary>
  38. public static TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds (30);
  39. }