2
0

ColorTests.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 ColorTests {
  7. [Theory]
  8. [InlineData (typeof (FakeDriver))]
  9. //[InlineData (typeof (NetDriver))]
  10. //[InlineData (typeof (CursesDriver))]
  11. //[InlineData (typeof (WindowsDriver))]
  12. public void SetColors_Changes_Colors (Type driverType)
  13. {
  14. var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
  15. Application.Init (driver);
  16. driver.Init (() => { });
  17. Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
  18. Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
  19. Console.ForegroundColor = ConsoleColor.Red;
  20. Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
  21. Console.BackgroundColor = ConsoleColor.Green;
  22. Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);
  23. Console.ResetColor ();
  24. Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
  25. Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
  26. driver.End ();
  27. // Shutdown must be called to safely clean up Application if Init has been called
  28. Application.Shutdown ();
  29. }
  30. [Fact, AutoInitShutdown]
  31. public void ColorScheme_New ()
  32. {
  33. var scheme = new ColorScheme ();
  34. var lbl = new Label ();
  35. lbl.ColorScheme = scheme;
  36. lbl.Redraw (lbl.Bounds);
  37. }
  38. }
  39. }