I have a logic module for a turn based game (no UI yet), which uses async user input (parsed from console, until the real UI gets done), and in some cases generates random numbers ("die rolls") and makes changes in the game state-model based on the inputs and the random numbers.
Reading this thread and this thread, I was wondering if it was possible to use something similiar. My game logic has a single Random instance, so it should be relatively easy to swap that out.
So what do I have to do?
- Swap out GameLogic.Random to an IRandom, and put either a Random or a pregenerated sequence into it based on whether I'm testing
- Swap out Console.ReadLine() with IConsole.ReadLine() everywhere in my command parser so I don't have to type it in every time
- Swap out Console.WriteLine() with IConsole.WriteLine() so it prints to a file, where I can read the results
And then I can use my classes from a Unit Test? That's all??