DriverColorTests.cs 2.0 KB

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