I am new to TDD and trying to solve the problem.
In my task, I have to read a bunch of lines from the console and add them to the line type list. In my testing method, I wrote a for loop to read lines and move on to the add method. I do not know how to test this process, a little confused. Any help would be appreciated. Thank you
Loop in the testing method.
for(int i=0;i<robot.noOfCommands;i++) { robot.readCommand(Console.ReadLine()); }
I am writing code in C # .Net
Unit tests should never require human interaction, so using Console.ReadLine () is a big no-no.
, , , , , robot . (Assert), - , . .
robot
Assert
, , System.Console. , ( ), - .
System.Console
Console.ReadLine TextReader. :
Console.ReadLine
TextReader
public void MyMethod(TextReader reader) { for (int i = 0; i < robot.noOfCommands; i++) { robot.readCommand(reader.ReadLine()); } }
MyMethod(Console.In). (, ) .
MyMethod(Console.In)