Skip to content

Commit

Permalink
Merge pull request #3476 from BDisp/v2_3475_fakedriver-cols-rows-fix
Browse files Browse the repository at this point in the history
Fixes #3475. FakeConsole throws System.IndexOutOfRangeException using SetupFakeDriverAttribute.
  • Loading branch information
tig committed May 30, 2024
2 parents 79ff001 + d8ec2a8 commit 7451e79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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

0 comments on commit 7451e79

Please sign in to comment.