DriverColorTests.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Alias Console to MockConsole so we don't accidentally use Console
  2. using Console = Terminal.Gui.FakeConsole;
  3. namespace Terminal.Gui.DriverTests;
  4. public class DriverColorTests
  5. {
  6. public DriverColorTests () { ConsoleDriver.RunningUnitTests = true; }
  7. [Theory]
  8. [InlineData (typeof (FakeDriver))]
  9. [InlineData (typeof (NetDriver))]
  10. //[InlineData (typeof (ANSIDriver))]
  11. [InlineData (typeof (WindowsDriver))]
  12. [InlineData (typeof (CursesDriver))]
  13. public void Force16Colors_Sets (Type driverType)
  14. {
  15. var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
  16. driver.Init ();
  17. driver.Force16Colors = true;
  18. Assert.True (driver.Force16Colors);
  19. driver.End ();
  20. }
  21. [Theory]
  22. [InlineData (typeof (FakeDriver))]
  23. [InlineData (typeof (NetDriver))]
  24. //[InlineData (typeof (ANSIDriver))]
  25. [InlineData (typeof (WindowsDriver))]
  26. [InlineData (typeof (CursesDriver))]
  27. public void SetColors_Changes_Colors (Type driverType)
  28. {
  29. var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
  30. driver.Init ();
  31. Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
  32. Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
  33. Console.ForegroundColor = ConsoleColor.Red;
  34. Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
  35. Console.BackgroundColor = ConsoleColor.Green;
  36. Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);
  37. Console.ResetColor ();
  38. Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
  39. Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
  40. driver.End ();
  41. }
  42. [Theory]
  43. [InlineData (typeof (FakeDriver), false)]
  44. [InlineData (typeof (NetDriver), true)]
  45. //[InlineData (typeof (ANSIDriver), true)]
  46. [InlineData (typeof (WindowsDriver), true)]
  47. [InlineData (typeof (CursesDriver), true)]
  48. public void SupportsTrueColor_Defaults (Type driverType, bool expectedSetting)
  49. {
  50. var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
  51. driver.Init ();
  52. Assert.Equal (expectedSetting, driver.SupportsTrueColor);
  53. driver.End ();
  54. }
  55. }