Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 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
12 changes: 12 additions & 0 deletions src/Platform/Microsoft.Testing.Platform/Helpers/System/IConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ internal interface IConsole
[UnsupportedOSPlatform("tvos")]
int BufferWidth { get; }

[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
int WindowHeight { get; }

[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
int WindowWidth { get; }

bool IsOutputRedirected { get; }

[UnsupportedOSPlatform("android")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ internal sealed class SystemConsole : IConsole
[UnsupportedOSPlatform("tvos")]
public int BufferWidth => Console.BufferWidth;

/// <summary>
/// Gets the height of the console window area.
/// </summary>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public int WindowHeight => Console.WindowHeight;

/// <summary>
/// Gets the width of the console window area.
/// </summary>
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
public int WindowWidth => Console.WindowWidth;

/// <summary>
/// Gets a value indicating whether output has been redirected from the standard output stream.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public AnsiTerminal(IConsole console)
public int Width
=> _console.IsOutputRedirected || OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()
? int.MaxValue
: _console.BufferWidth;
: _console.WindowWidth;

public int Height
=> _console.IsOutputRedirected || OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()
? int.MaxValue
: _console.BufferHeight;
: _console.WindowHeight;

public void Append(char value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public SimpleTerminal(IConsole console)
public int Width
=> Console.IsOutputRedirected || OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()
? int.MaxValue
: Console.BufferWidth;
: Console.WindowWidth;

public int Height
=> Console.IsOutputRedirected || OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()
? int.MaxValue
: Console.BufferHeight;
: Console.WindowHeight;

protected IConsole Console { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@

public int BufferWidth => int.MinValue;

public int WindowHeight => int.MaxValue;

public int WindowWidth => 120;

public bool IsOutputRedirected => false;

public string Output => _output.ToString();
Expand Down Expand Up @@ -809,4 +813,65 @@
// Assert - should contain information about 2 tests discovered
Assert.IsTrue(output.Contains('2') || output.Contains("TestMethod1"), "Output should contain information about discovered tests");
}

[TestMethod]
public void SimpleTerminal_UsesWindowWidthNotBufferWidth()
{
// Arrange - Create a console where BufferWidth and WindowWidth are different
var console = new TestConsoleWithDifferentBufferAndWindowWidth
{
BufferWidth = 4096,
WindowWidth = 120

Check failure on line 824 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L824

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(824,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)

Check failure on line 824 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L824

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(824,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)

Check failure on line 824 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L824

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(824,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)

Check failure on line 824 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L824

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(824,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)

Check failure on line 824 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L824

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(824,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)
};

var terminal = new NonAnsiTerminal(console);

// Assert - Width should use WindowWidth, not BufferWidth
Assert.AreEqual(120, terminal.Width);
}

[TestMethod]
public void AnsiTerminal_UsesWindowWidthNotBufferWidth()
{
// Arrange - Create a console where BufferWidth and WindowWidth are different
var console = new TestConsoleWithDifferentBufferAndWindowWidth
{
BufferWidth = 4096,
WindowWidth = 120

Check failure on line 840 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L840

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(840,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)

Check failure on line 840 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L840

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(840,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)

Check failure on line 840 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L840

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(840,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)

Check failure on line 840 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L840

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(840,13): error SA1413: (NETCORE_ENGINEERING_TELEMETRY=Build) Use trailing comma in multi-line initializers (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md)
};

var terminal = new AnsiTerminal(console);

// Assert - Width should use WindowWidth, not BufferWidth
Assert.AreEqual(120, terminal.Width);
}

internal class TestConsoleWithDifferentBufferAndWindowWidth : IConsole
{
public int BufferHeight { get; set; } = 300;

public int BufferWidth { get; set; } = 4096;

public int WindowHeight { get; set; } = 30;

public int WindowWidth { get; set; } = 120;

public bool IsOutputRedirected => false;

public event ConsoleCancelEventHandler? CancelKeyPress = (sender, e) => { };

public void Clear() => throw new NotImplementedException();

public ConsoleColor GetForegroundColor() => ConsoleColor.White;

public void SetForegroundColor(ConsoleColor color) { }

Check failure on line 867 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L867

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(867,60): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 867 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L867

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(867,60): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 867 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L867

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(867,60): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 867 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L867

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(867,60): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

public void Write(string? value) { }

Check failure on line 869 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L869

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(869,42): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 869 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L869

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(869,42): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 869 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L869

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(869,42): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 869 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L869

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(869,42): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

public void Write(char value) { }

Check failure on line 871 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L871

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(871,39): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 871 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L871

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(871,39): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

Check failure on line 871 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs#L871

test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs(871,39): error SA1502: (NETCORE_ENGINEERING_TELEMETRY=Build) Element should not be on a single line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md)

public void WriteLine() { }

public void WriteLine(string? value) { }
}
}
Loading