With.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 : IRunnable, 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="runnableFactory"/> after application is initialized.
  25. /// </summary>
  26. /// <param name="runnableFactory"></param>
  27. /// <param name="width"></param>
  28. /// <param name="height"></param>
  29. /// <param name="testDriver"></param>
  30. /// <param name="logWriter"></param>
  31. /// <returns></returns>
  32. public static GuiTestContext A (Func<IRunnable> runnableFactory, int width, int height, TestDriver testDriver, TextWriter? logWriter = null)
  33. {
  34. return new (runnableFactory, width, height, testDriver, logWriter, Timeout);
  35. }
  36. /// <summary>
  37. /// The global timeout to allow for any given application to run for before shutting down.
  38. /// </summary>
  39. public static TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds (30);
  40. }