I am new to TDD and trying to solve a problem.
In my task, I have to read a bunch of strings from console and add them to a list of string type. In my test method, I have written a for loop to read strings and passing to a method to add. I don’t know how to test this process, a bit confused. Any help will be appreciated. Thanks.
Loop in the test 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 major no-no.
What you probably want, is to feed your
robotobject with some predefined input. Then you can test (Assert), that the outcome is what you expect. That is the essence of unit testing.