I have class, which is using Console
class and sets this variables in constructor.
public Scene() {
Height = Console.WindowHeight;
Width = Console.WindowWidth;
}
and test class, which tests this constructor:
public class SceneTests {
[Fact]
public void Contructor_None_ShouldReturnScene() {
var testScene = new Scene();
Assert.Equal(Console.WindowHeight, testScene.Height);
Assert.Equal(Console.WindowWidth, testScene.Width);
}
}
But while running this test I've got Exeption:
Exception has occurred: CLR/System.IO.IOException
An exception of type 'System.IO.IOException' occurred in System.Console.dll but was not handled in user code: 'Nieprawidłowe dojście'
at System.ConsolePal.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at System.ConsolePal.get_WindowHeight()
at System.Console.get_WindowHeight()
I guess, that's because I don't have actual Console
window.
Can I somehow simulate that? Maybe simple creating buffer manually and adding it to Console
will solve the problem.