I know I can call Console.SetIn()
and pass in a StringReader
. When I call Console.ReadLine()
it works as expected and returns the string
from the StringReader
but here's the question:
Is there a way to get Console.ReadKey()
to behave similarly and read a single char
without using Moq (or other mocking framework)?
Here's a link to an example using Console.ReadLine()
as I've described in case it's not clear.
https://makolyte.com/csharp-how-to-unit-test-code-that-reads-and-writes-to-the-console/