Files
Terminal.Gui/Tests/UnitTestsParallelizable/Views/TextFieldTests.cs
Copilot e6a0ec64ca Fixes #4361 - Consolidate FakeDriver into library and refactor driver architecture (#4362)
* Initial plan

* Add ScreenChanged event, SetScreenSize method, and fix FakeDriver buffer initialization

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Add comprehensive tests for ScreenChanged event and buffer integrity

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Replace obsolete SizeChanged usage with ScreenChanged in core and tests

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Refactor terminal size event handling

Replaced `ScreenChanged` with `SizeChanged` across the codebase to standardize naming and improve clarity. Updated event handling logic, including subscriptions, unsubscriptions, and raising methods. Removed deprecated `ScreenChanged` event and backward compatibility code.

Refactored driver initialization to handle legacy `IConsoleDriver` types separately. Updated tests and mock implementations to align with the new `SizeChanged` event. Improved documentation and comments to reflect these changes.

These updates enhance maintainability, consistency, and modernize the architecture.

* Refactor & Code Cleanup: Replace IWindowSizeMonitor with IConsoleSizeMonitor

Renamed `IWindowSizeMonitor` to `IConsoleSizeMonitor` across the codebase, updating all references, method signatures, and event handlers. Replaced the `WindowSizeMonitor` class with the new `ConsoleSizeMonitor` implementation, which includes improved terminal size change handling via the `Poll` method.

Enabled nullable reference types in several files to enhance code safety. Updated test cases to reflect the new `IConsoleSizeMonitor` interface. Removed redundant code, simplified null checks, and corrected minor typos in comments. Streamlined the codebase by removing the obsolete `WindowSizeMonitor` class and its interface.

* Code cleanup - Refactor and enhance ShadowView and FakeDriverTests

Updated ShadowView.cs to use null-conditional operators and added null checks for safer access to `ScreenContents`. Refined XML documentation in View.Layout.cs for clarity and consistency.

Refactored FakeDriverTests.cs to leverage modern C# features, including shorthand object instantiation, inline lambdas, and tuple-like syntax for `Size` and `Rectangle`. Removed redundant tests and improved test readability and reliability.

Enhanced error handling with null checks and ensured backward compatibility for deprecated events. Improved test coverage for resizing, clipboard operations, and invalid coordinates. Verified buffer integrity and screen updates after resizing.

General improvements include replacing explicit type declarations with `var`, removing unused imports, and aligning code formatting for better readability.

Refactor and improve code quality and test coverage

Updated `ShadowView` for null safety using null-conditional operators. Simplified object initializations and modernized syntax across the codebase, including shorthand initializations and inline lambdas. Enhanced event handling logic and ensured compatibility with obsolete members.

Refactored `FakeDriverTests` by removing redundant code, standardizing formatting, and improving test setup. Suppressed obsolete warnings where necessary. Improved XML documentation in `View.Layout.cs` for clarity and removed outdated references.

Performed general cleanup, including removing unused namespaces, redundant comments, and ensuring consistent formatting. These changes enhance readability, maintainability, and runtime safety.

* Code cleanup

Refactor TimedEventsTests for readability and consistency

Improved code readability and maintainability:
- Enabled nullable reference types with `#nullable enable`.
- Removed unused `using System.Diagnostics;`.
- Updated namespace to `UnitTests.ApplicationTests`.
- Replaced `Terminal.Gui.App.TimedEvents` with `TimedEvents`.
- Reformatted XML documentation comments for alignment.
- Used `var` and target-typed new expressions for consistency.
- Reformatted `Parallel.For` loops and lambdas for clarity.
- Added `Thread.Sleep(10)` to prevent excessive CPU usage in tests.
- Improved assertions and event handler formatting in tests.

Aligned with modern C# coding practices.

* Code Cleanup - No more driver warnings.

Refactor codebase and introduce FakeClipboard

- Adjusted `.editorconfig` to change severity levels for CS0612, CS0618, and CS0672 diagnostics.
- Replaced `FakeDriver.FakeClipboard` with a new `FakeClipboard` class for testing purposes, supporting exception handling and clipboard data manipulation.
- Removed redundant methods (`MakeColor`, `MapKey`) and unused classes (`MockConsoleDriver`) to streamline the codebase.
- Refactored `ConsoleDriverFacade` and `FakeDriver` to simplify logic and improve maintainability.
- Updated tests to use `CreateFakeDriver` and removed or commented out obsolete tests.
- Reformatted and cleaned up code for readability across multiple files.

* Refactor FakeDriver - Code Cleanup

Standardized console size management by replacing `WindowSizeMonitor` with `ConsoleSizeMonitor` across the codebase. Updated methods `GetWindowSize` and `SetWindowSize` to `GetSize` and `SetSize` for consistency.

Refactored `FakeDriver` to use `SetScreenSize` and removed redundant methods. Simplified driver initialization by removing legacy `InternalInit` logic.

Standardized ANSI escape sequences by replacing `CSI_ReportTerminalSizeInChars` with `CSI_ReportWindowSizeInChars`.

Updated test cases to align with the new `ConsoleSizeMonitor` and `SetScreenSize` methods. Removed obsolete test utilities like `FakeSizeMonitor` and `FakeWindowSizeMonitor`.

Performed general code cleanup, including removing unused classes, redundant code, and improving formatting. Fixed resizing logic issues and improved exception handling in driver methods.

* Update Terminal.Gui/Drivers/OutputBuffer.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Terminal.Gui/Drivers/MouseButtonStateEx.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Terminal.Gui/App/MainLoop/IApplicationMainLoop.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Tests/UnitTests/Views/ToplevelTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Terminal.Gui/ViewBase/View.Layout.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Moved all Drawing tests to Paralleizable - proving Fakedriver works

Enhanced `Ruler` and `Thickness` classes by adding an optional `IConsoleDriver? driver` parameter to decouple rendering from the default `Application.Driver`, improving flexibility and testability. Updated `DriverAssert` to support nullable drivers and added defensive checks.

Refactored and expanded test cases for `Ruler`, `Thickness`, `LineCanvas`, and `StraightLineExtensions` to ensure comprehensive coverage, including zero-length intersections, line rendering, and exclusion logic. Migrated rendering-dependent tests to a parallelizable namespace.

Removed redundant tests, improved naming conventions, and updated documentation for better maintainability and clarity.

* Fixed Run<T> startup hang.

Refactor: Simplify driver logic and update SetSize methods

Removed FakeDriver safeguard in unit tests to simplify
CreateDriver logic. Updated SetSize methods in NetOutput,
UnixOutput, and WindowsOutput to do nothing instead of
throwing NotImplementedException. Modified SizeChanged
event in ConsoleDriverFacade to call SetScreenSize directly.
Commented out unnecessary debug validation in DimAuto.
These changes improve maintainability and reduce complexity.

* Fixed intermittent unit test bug.

Refactored `_cachedRunStateToplevel` to `CachedRunStateToplevel` as an internal static property, delegating its management to `ApplicationImpl` for improved encapsulation. Updated all references to use the new property and centralized its handling in `ApplicationImpl`.

Removed the `MouseGrabHandler` property from `ApplicationImpl` and simplified driver-related assignments by replacing `Application.ForceDriver` and `Application.Screen` with direct references.

Reset `CachedRunStateToplevel` during cleanup to ensure proper state management. Updated the `Invoke` method to use `Top` directly, aligning with the refactored design. Improved debug assertions and performed general cleanup to enhance code readability and maintainability.

* Fixed intermittent bug an massive code cleanup of warnings.

Refactor and enhance codebase for maintainability

- Applied null-conditional operator (`!`) to improve null-safety.
- Refactored tests for clarity, added new cases, and removed redundancies.
- Introduced `FakeApplicationFactory` and `FakeSizeMonitor` for testing.
- Removed unused code, including legacy `DecodeEscSeq` logic.
- Reformatted code for readability and consistency.
- Updated assertions for more accurate validation in tests.
- Fixed potential null reference issues across multiple files.
- Improved event handling with proper null checks.
- Enhanced documentation for new classes and methods.
- Modernized code with C# features like `record struct` and `nullable enable`.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-27 23:34:14 -06:00

637 lines
17 KiB
C#
Raw Blame History

using System.Text;
using UnitTests;
using UnitTests.Parallelizable;
using Xunit.Abstractions;
namespace UnitTests_Parallelizable.ViewsTests;
public class TextFieldTests (ITestOutputHelper output) : ParallelizableBase
{
[Fact]
public void Cancel_TextChanging_ThenBackspace ()
{
var tf = new TextField ();
tf.SetFocus ();
tf.NewKeyDownEvent (Key.A.WithShift);
Assert.Equal ("A", tf.Text);
// cancel the next keystroke
tf.TextChanging += (s, e) => e.Handled = e.Result == "AB";
tf.NewKeyDownEvent (Key.B.WithShift);
// B was canceled so should just be A
Assert.Equal ("A", tf.Text);
// now delete the A
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("", tf.Text);
}
[Fact]
public void HistoryText_IsDirty_ClearHistoryChanges ()
{
var text = "Testing";
var tf = new TextField { Text = text };
tf.BeginInit ();
tf.EndInit ();
Assert.Equal (text, tf.Text);
tf.ClearHistoryChanges ();
Assert.False (tf.IsDirty);
Assert.True (tf.NewKeyDownEvent (Key.A.WithShift));
Assert.Equal ($"{text}A", tf.Text);
Assert.True (tf.IsDirty);
}
[Fact]
public void Space_Does_Not_Raise_Selected ()
{
TextField tf = new ();
tf.Selecting += (sender, args) => Assert.Fail ("Selected should not be raied.");
Toplevel top = new ();
top.Add (tf);
tf.SetFocus ();
top.NewKeyDownEvent (Key.Space);
top.Dispose ();
}
[Fact]
public void Enter_Does_Not_Raise_Selected ()
{
TextField tf = new ();
var selectingCount = 0;
tf.Selecting += (sender, args) => selectingCount++;
Toplevel top = new ();
top.Add (tf);
tf.SetFocus ();
top.NewKeyDownEvent (Key.Enter);
Assert.Equal (0, selectingCount);
top.Dispose ();
}
[Fact]
public void Enter_Raises_Accepted ()
{
TextField tf = new ();
var acceptedCount = 0;
tf.Accepting += (sender, args) => acceptedCount++;
Toplevel top = new ();
top.Add (tf);
tf.SetFocus ();
top.NewKeyDownEvent (Key.Enter);
Assert.Equal (1, acceptedCount);
top.Dispose ();
}
[Fact]
public void HotKey_Command_SetsFocus ()
{
var view = new TextField ();
view.CanFocus = true;
Assert.False (view.HasFocus);
view.InvokeCommand (Command.HotKey);
Assert.True (view.HasFocus);
}
[Fact]
public void HotKey_Command_Does_Not_Accept ()
{
var view = new TextField ();
var accepted = false;
view.Accepting += OnAccept;
view.InvokeCommand (Command.HotKey);
Assert.False (accepted);
return;
void OnAccept (object sender, CommandEventArgs e) { accepted = true; }
}
[Fact]
public void Accepted_Command_Fires_Accept ()
{
var view = new TextField ();
var accepted = false;
view.Accepting += Accept;
view.InvokeCommand (Command.Accept);
Assert.True (accepted);
return;
void Accept (object sender, CommandEventArgs e) { accepted = true; }
}
[Fact]
public void Accepted_No_Handler_Enables_Default_Button_Accept ()
{
var superView = new Window
{
Id = "superView"
};
var tf = new TextField
{
Id = "tf"
};
var button = new Button
{
Id = "button",
IsDefault = true
};
superView.Add (tf, button);
var buttonAccept = 0;
button.Accepting += ButtonAccept;
tf.SetFocus ();
Assert.True (tf.HasFocus);
superView.NewKeyDownEvent (Key.Enter);
Assert.Equal (1, buttonAccept);
button.SetFocus ();
superView.NewKeyDownEvent (Key.Enter);
Assert.Equal (2, buttonAccept);
return;
void ButtonAccept (object sender, CommandEventArgs e) { buttonAccept++; }
}
[Fact]
public void Accepted_Cancel_Event_HandlesCommand ()
{
//var super = new View ();
var view = new TextField ();
//super.Add (view);
//var superAcceptedInvoked = false;
var tfAcceptedInvoked = false;
var handle = false;
view.Accepting += TextViewAccept;
Assert.False (view.InvokeCommand (Command.Accept));
Assert.True (tfAcceptedInvoked);
tfAcceptedInvoked = false;
handle = true;
view.Accepting += TextViewAccept;
Assert.True (view.InvokeCommand (Command.Accept));
Assert.True (tfAcceptedInvoked);
return;
void TextViewAccept (object sender, CommandEventArgs e)
{
tfAcceptedInvoked = true;
e.Handled = handle;
}
}
[Fact]
public void OnEnter_Does_Not_Throw_If_Not_IsInitialized_SetCursorVisibility ()
{
var top = new Toplevel ();
var tf = new TextField { Width = 10 };
top.Add (tf);
Exception exception = Record.Exception (() => tf.SetFocus ());
Assert.Null (exception);
}
[Fact]
public void Backspace_From_End ()
{
var tf = new TextField { Text = "ABC" };
tf.SetFocus ();
Assert.Equal ("ABC", tf.Text);
tf.BeginInit ();
tf.EndInit ();
Assert.Equal (3, tf.CursorPosition);
// now delete the C
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("AB", tf.Text);
Assert.Equal (2, tf.CursorPosition);
// then delete the B
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("A", tf.Text);
Assert.Equal (1, tf.CursorPosition);
// then delete the A
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("", tf.Text);
Assert.Equal (0, tf.CursorPosition);
}
[Fact]
public void Backspace_From_Middle ()
{
var tf = new TextField { Text = "ABC" };
tf.SetFocus ();
tf.CursorPosition = 2;
Assert.Equal ("ABC", tf.Text);
// now delete the B
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("AC", tf.Text);
// then delete the A
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("C", tf.Text);
// then delete nothing
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("C", tf.Text);
// now delete the C
tf.CursorPosition = 1;
tf.NewKeyDownEvent (Key.Backspace);
Assert.Equal ("", tf.Text);
}
[Fact]
public void KeyDown_Handled_Prevents_Input ()
{
var tf = new TextField ();
tf.KeyDown += HandleJKey;
tf.NewKeyDownEvent (Key.A);
Assert.Equal ("a", tf.Text);
// SuppressKey suppresses the 'j' key
tf.NewKeyDownEvent (Key.J);
Assert.Equal ("a", tf.Text);
tf.KeyDown -= HandleJKey;
// Now that the delegate has been removed we can type j again
tf.NewKeyDownEvent (Key.J);
Assert.Equal ("aj", tf.Text);
return;
void HandleJKey (object s, Key arg)
{
if (arg.AsRune == new Rune ('j'))
{
arg.Handled = true;
}
}
}
[InlineData ("a")] // Lower than selection
[InlineData ("aaaaaaaaaaa")] // Greater than selection
[InlineData ("aaaa")] // Equal than selection
[Theory]
public void SetTextAndMoveCursorToEnd_WhenExistingSelection (string newText)
{
var tf = new TextField ();
tf.Text = "fish";
tf.CursorPosition = tf.Text.Length;
tf.NewKeyDownEvent (Key.CursorLeft);
tf.NewKeyDownEvent (Key.CursorLeft.WithShift);
tf.NewKeyDownEvent (Key.CursorLeft.WithShift);
Assert.Equal (1, tf.CursorPosition);
Assert.Equal (2, tf.SelectedLength);
Assert.Equal ("is", tf.SelectedText);
tf.Text = newText;
tf.CursorPosition = tf.Text.Length;
Assert.Equal (newText.Length, tf.CursorPosition);
Assert.Equal (0, tf.SelectedLength);
Assert.Null (tf.SelectedText);
}
[Fact]
public void SpaceHandling ()
{
var tf = new TextField { Width = 10, Text = " " };
var ev = new MouseEventArgs { Position = new (0, 0), Flags = MouseFlags.Button1DoubleClicked };
tf.NewMouseEvent (ev);
Assert.Equal (1, tf.SelectedLength);
ev = new () { Position = new (1, 0), Flags = MouseFlags.Button1DoubleClicked };
tf.NewMouseEvent (ev);
Assert.Equal (1, tf.SelectedLength);
}
[Fact]
public void WordBackward_WordForward_Mixed ()
{
var tf = new TextField { Width = 30, Text = "Test with0. and!.?;-@+" };
tf.BeginInit ();
tf.EndInit ();
Assert.False (tf.UseSameRuneTypeForWords);
Assert.Equal (22, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorLeft.WithCtrl);
Assert.Equal (15, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorLeft.WithCtrl);
Assert.Equal (12, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorLeft.WithCtrl);
Assert.Equal (10, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorLeft.WithCtrl);
Assert.Equal (5, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorLeft.WithCtrl);
Assert.Equal (0, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorRight.WithCtrl);
Assert.Equal (5, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorRight.WithCtrl);
Assert.Equal (10, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorRight.WithCtrl);
Assert.Equal (12, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorRight.WithCtrl);
Assert.Equal (15, tf.CursorPosition);
tf.NewKeyDownEvent (Key.CursorRight.WithCtrl);
Assert.Equal (22, tf.CursorPosition);
}
[Fact]
public void WordBackward_WordForward_SelectedText_With_Accent ()
{
var text = "Les Misérables movie.";
var tf = new TextField { Width = 30, Text = text };
Assert.Equal (21, text.Length);
Assert.Equal (21, tf.Text.GetRuneCount ());
Assert.Equal (21, tf.Text.GetColumns ());
List<Rune> runes = tf.Text.ToRuneList ();
Assert.Equal (21, runes.Count);
Assert.Equal (21, tf.Text.Length);
for (var i = 0; i < runes.Count; i++)
{
char cs = text [i];
var cus = (char)runes [i].Value;
Assert.Equal (cs, cus);
}
var idx = 15;
Assert.Equal ('m', text [idx]);
Assert.Equal ('m', (char)runes [idx].Value);
Assert.Equal ("m", runes [idx].ToString ());
Assert.True (
tf.NewMouseEvent (
new () { Position = new (idx, 1), Flags = MouseFlags.Button1DoubleClicked, View = tf }
)
);
Assert.Equal ("movie", tf.SelectedText);
Assert.True (
tf.NewMouseEvent (
new () { Position = new (idx + 1, 1), Flags = MouseFlags.Button1DoubleClicked, View = tf }
)
);
Assert.Equal ("movie", tf.SelectedText);
}
[Fact]
public void Autocomplete_Popup_Added_To_SuperView_On_Init ()
{
View superView = new ()
{
CanFocus = true
};
TextField t = new ();
superView.Add (t);
Assert.Single (superView.SubViews);
superView.BeginInit ();
superView.EndInit ();
Assert.Equal (2, superView.SubViews.Count);
}
[Fact]
public void Autocomplete__Added_To_SuperView_On_Add ()
{
View superView = new ()
{
CanFocus = true,
Id = "superView"
};
superView.BeginInit ();
superView.EndInit ();
Assert.Empty (superView.SubViews);
TextField t = new ()
{
Id = "t"
};
superView.Add (t);
Assert.Equal (2, superView.SubViews.Count);
}
[Fact]
public void Right_CursorAtEnd_WithSelection_ShouldClearSelection ()
{
var tf = new TextField
{
Text = "Hello"
};
tf.SetFocus ();
tf.SelectAll ();
tf.CursorPosition = 5;
// When there is selected text and the cursor is at the end of the text field
Assert.Equal ("Hello", tf.SelectedText);
// Pressing right should not move focus, instead it should clear selection
Assert.True (tf.NewKeyDownEvent (Key.CursorRight));
Assert.Null (tf.SelectedText);
// Now that the selection is cleared another right keypress should move focus
Assert.False (tf.NewKeyDownEvent (Key.CursorRight));
}
[Fact]
public void Left_CursorAtStart_WithSelection_ShouldClearSelection ()
{
var tf = new TextField
{
Text = "Hello"
};
tf.SetFocus ();
tf.CursorPosition = 2;
Assert.True (tf.NewKeyDownEvent (Key.CursorLeft.WithShift));
Assert.True (tf.NewKeyDownEvent (Key.CursorLeft.WithShift));
// When there is selected text and the cursor is at the start of the text field
Assert.Equal ("He", tf.SelectedText);
// Pressing left should not move focus, instead it should clear selection
Assert.True (tf.NewKeyDownEvent (Key.CursorLeft));
Assert.Null (tf.SelectedText);
// When clearing selected text with left the cursor should be at the start of the selection
Assert.Equal (0, tf.CursorPosition);
// Now that the selection is cleared another left keypress should move focus
Assert.False (tf.NewKeyDownEvent (Key.CursorLeft));
}
[Fact]
public void Autocomplete_Visible_False_By_Default ()
{
View superView = new ()
{
CanFocus = true
};
TextField t = new ();
superView.Add (t);
superView.BeginInit ();
superView.EndInit ();
Assert.Equal (2, superView.SubViews.Count);
Assert.True (t.Visible);
Assert.False (t.Autocomplete.Visible);
}
[Fact]
public void InsertText_Bmp_SurrogatePair_Non_Bmp_Invalid_SurrogatePair ()
{
var tf = new TextField ();
//📄 == \ud83d\udcc4 == \U0001F4C4
// <20> == Rune.ReplacementChar
tf.InsertText ("aA,;\ud83d\udcc4\U0001F4C4\udcc4\ud83d");
Assert.Equal ("aA,;📄📄<F09F9384><F09F9384>", tf.Text);
}
[Fact]
public void PositionCursor_Respect_GetColumns ()
{
var tf = new TextField { Width = 5 };
tf.BeginInit ();
tf.EndInit ();
tf.NewKeyDownEvent (new ("📄"));
Assert.Equal (1, tf.CursorPosition);
Assert.Equal (new (2, 0), tf.PositionCursor ());
Assert.Equal ("📄", tf.Text);
tf.NewKeyDownEvent (new (KeyCode.A));
Assert.Equal (2, tf.CursorPosition);
Assert.Equal (new (3, 0), tf.PositionCursor ());
Assert.Equal ("📄a", tf.Text);
}
[Fact]
public void Accented_Letter_With_Three_Combining_Unicode_Chars ()
{
IConsoleDriver driver = CreateFakeDriver ();
var tf = new TextField { Width = 3, Text = "ắ" };
tf.Driver = driver;
tf.Layout ();
tf.Draw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@"
ắ",
output,
driver
);
tf.Text = "\u1eaf";
tf.Layout ();
tf.Draw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@"
ắ",
output,
driver
);
tf.Text = "\u0103\u0301";
tf.Layout ();
tf.Draw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@"
ắ",
output,
driver
);
tf.Text = "\u0061\u0306\u0301";
tf.Layout ();
tf.Draw ();
DriverAssert.AssertDriverContentsWithFrameAre (
@"
ắ",
output,
driver
);
}
[Fact]
public void Adjust_First ()
{
IConsoleDriver driver = CreateFakeDriver ();
var tf = new TextField { Width = Dim.Fill (), Text = "This is a test." };
tf.Driver = driver;
tf.SetRelativeLayout (new (20, 20));
tf.Draw ();
Assert.Equal ("This is a test. ", GetContents ());
string GetContents ()
{
var item = "";
for (var i = 0; i < 16; i++)
{
item += driver.Contents [0, i]!.Rune;
}
return item;
}
}
}