12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System;
- using Xunit;
- // Alias Console to MockConsole so we don't accidentally use Console
- using Console = Terminal.Gui.FakeConsole;
- namespace Terminal.Gui.DriverTests {
- public class DriverColorTests {
- public DriverColorTests ()
- {
- ConsoleDriver.RunningUnitTests = true;
- }
-
- [Theory]
- [InlineData (typeof (FakeDriver))]
- [InlineData (typeof (NetDriver))]
- [InlineData (typeof (CursesDriver))]
- [InlineData (typeof (WindowsDriver))]
- public void SetColors_Changes_Colors (Type driverType)
- {
- var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
- Application.Init (driver);
- Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
- Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
- Console.ForegroundColor = ConsoleColor.Red;
- Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
- Console.BackgroundColor = ConsoleColor.Green;
- Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);
- Console.ResetColor ();
- Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
- Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
- // Shutdown must be called to safely clean up Application if Init has been called
- Application.Shutdown ();
- }
- [Theory]
- [InlineData (typeof (FakeDriver), false)]
- [InlineData (typeof (NetDriver), true)]
- [InlineData (typeof (CursesDriver), false)]
- [InlineData (typeof (WindowsDriver), true)] // Because we're not Windows Terminal
- public void SupportsTrueColor_Defaults (Type driverType, bool expectedSetting)
- {
- var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
- driver.Init ();
- Assert.Equal (expectedSetting, driver.SupportsTrueColor);
- driver.End ();
- // Shutdown must be called to safely clean up Application if Init has been called
- Application.Shutdown ();
- }
- [Theory]
- [InlineData (typeof (FakeDriver))]
- [InlineData (typeof (NetDriver))]
- [InlineData (typeof (CursesDriver))]
- [InlineData (typeof (WindowsDriver))]
- public void Force16Colors_Sets (Type driverType)
- {
- var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
- driver.Init ();
- driver.Force16Colors = true;
- Assert.True (driver.Force16Colors);
- driver.End ();
- // Shutdown must be called to safely clean up Application if Init has been called
- Application.Shutdown ();
- }
- }
- }
|