DriverTests.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #nullable enable
  2. using Xunit.Abstractions;
  3. namespace UnitTests.DriverTests;
  4. public class DriverTests (ITestOutputHelper output)
  5. {
  6. private readonly ITestOutputHelper _output = output;
  7. [Theory]
  8. [InlineData ("fake")]
  9. [InlineData ("windows")]
  10. [InlineData ("dotnet")]
  11. [InlineData ("unix")]
  12. public void All_Drivers_Init_Shutdown_Cross_Platform (string driverName)
  13. {
  14. IApplication? app = Application.Create ();
  15. app.Init (driverName);
  16. app.Shutdown ();
  17. }
  18. [Theory]
  19. [InlineData ("fake")]
  20. [InlineData ("windows")]
  21. [InlineData ("dotnet")]
  22. [InlineData ("unix")]
  23. public void All_Drivers_Run_Cross_Platform (string driverName)
  24. {
  25. IApplication? app = Application.Create ();
  26. app.Init (driverName);
  27. app.StopAfterFirstIteration = true;
  28. app.Run ().Dispose ();
  29. app.Shutdown ();
  30. }
  31. [Theory]
  32. [InlineData ("fake")]
  33. [InlineData ("windows")]
  34. [InlineData ("dotnet")]
  35. [InlineData ("unix")]
  36. public void All_Drivers_LayoutAndDraw_Cross_Platform (string driverName)
  37. {
  38. IApplication? app = Application.Create ();
  39. app.Init (driverName);
  40. app.StopAfterFirstIteration = true;
  41. app.Run<TestTop> ().Dispose ();
  42. DriverAssert.AssertDriverContentsWithFrameAre (driverName!, _output, app.Driver);
  43. app.Shutdown ();
  44. }
  45. }
  46. public class TestTop : Toplevel
  47. {
  48. /// <inheritdoc/>
  49. public override void BeginInit ()
  50. {
  51. Text = Driver!.GetName ()!;
  52. BorderStyle = LineStyle.None;
  53. base.BeginInit ();
  54. }
  55. }