Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3475. FakeConsole throws System.IndexOutOfRangeException using SetupFakeDriverAttribute. #3476

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ public class Behaviors
public static Behaviors FakeBehaviors = new ();
public override bool SupportsTrueColor => false;

/// <inheritdoc />
public override int Cols
{
get => base.Cols;
internal set
{
base.Cols = value;
FakeConsole.SetBufferSize (Cols, Rows);
}
}

/// <inheritdoc />
public override int Rows
{
get => base.Rows;
internal set
{
base.Rows = value;
FakeConsole.SetBufferSize (Cols, Rows);
}
}

public FakeDriver ()
{
Cols = FakeConsole.WindowWidth = FakeConsole.BufferWidth = FakeConsole.WIDTH;
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public override void Before (MethodInfo methodUnderTest)
Debug.WriteLine ($"Before: {methodUnderTest.Name}");
Assert.Null (Application.Driver);
Application.Driver = new FakeDriver { Rows = 25, Cols = 25 };
Assert.Equal (FakeConsole.BufferWidth, Application.Driver.Cols);
Assert.Equal (FakeConsole.BufferHeight, Application.Driver.Rows);
base.Before (methodUnderTest);
}
}
Expand Down
Loading