Files
Terminal.Gui/UnitTests/ConsoleDriverTests.cs
Charlie Kindel b29240f362 Code coverage (#1235)
* tweaked version # for v1.0.0-beta.10

* tweaked version # for v1.0.0-beta.11

* Updated readme and revision history for 1.0

* excluding test results

* Added support for viewing code coverage results with Fine Code Coverage

* add generating CC to CI/CD

* refactored unit test namespaces

* more refactoring. commented out failing test.

* Removed UnitTests and UICatalog from code coverage reporting

* made Application and test more deterministic

* disabled Multi_Thread_Toplevels because it is currently broken and don't understand why

* updated threading test per @bdisp

* testing cc badge stuff

* another test

* using coverlet.settings

* trying copy

* trying cp. duh.

* trying mv.

* wrong path

* print

* chaging badge output for testing

* yaml error

* fixed code coverage

* moved dimtests to core
2021-04-25 10:18:31 -07:00

71 lines
2.1 KiB
C#

using System;
using Terminal.Gui;
using Xunit;
// Alais Console to MockConsole so we don't accidentally use Console
using Console = Terminal.Gui.FakeConsole;
namespace Terminal.Gui.ConsoleDrivers {
public class ConsoleDriverTests {
[Fact]
public void Init_Inits ()
{
var driver = new FakeDriver ();
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
driver.Init (() => { });
Assert.Equal (80, Console.BufferWidth);
Assert.Equal (25, Console.BufferHeight);
// MockDriver is always 80x25
Assert.Equal (Console.BufferWidth, driver.Cols);
Assert.Equal (Console.BufferHeight, driver.Rows);
driver.End ();
}
[Fact]
public void End_Cleans_Up ()
{
var driver = new FakeDriver ();
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
driver.Init (() => { });
FakeConsole.ForegroundColor = ConsoleColor.Red;
Assert.Equal (ConsoleColor.Red, Console.ForegroundColor);
FakeConsole.BackgroundColor = ConsoleColor.Green;
Assert.Equal (ConsoleColor.Green, Console.BackgroundColor);
driver.Move (2, 3);
Assert.Equal (2, Console.CursorLeft);
Assert.Equal (3, Console.CursorTop);
driver.End ();
Assert.Equal (0, Console.CursorLeft);
Assert.Equal (0, Console.CursorTop);
Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
}
[Fact]
public void SetColors_Changes_Colors ()
{
var driver = new FakeDriver ();
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
driver.Init (() => { });
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);
driver.End ();
}
}
}