I am currently working on a C# project. I have just started needing to learn how to do unit tests and am finding them pretty difficult to get my head around some parts of it. I have a function which returns a List array and I need to test this method is working correctly.
When I right click on the method in VS2010 and say create Unit Test it creates me the following code:
[TestMethod()]
public void readStreamTest()
{
ReadStream target = new ReadStream(); // TODO: Initialize to an appropriate value
Stream stream = new MemoryStream(); // TODO: Initialize to an appropriate value
StreamWriter sw = new StreamWriter(stream);
string line = "My Line 1\n¬My Line 2\nMy Line 3\nMy Line 4\nMy Line 5\nMy Line 6\nMy Line 7";
int numLines = 5; // TODO: Initialize to an appropriate value
List<FileLine> lines = new List<FileLine>();
int i = 0;
while ( i != 7 )
{
lines.Add(new FileLine()
{
lineNo = i,
lineContent = line
});
i++;
}
List<FileLine> expected = lines; // TODO: Initialize to an appropriate value
List<FileLine> actual;
actual = target.readStream(stream, numLines);
//Assert.AreEqual(expected, actual);
Assert.IsNotNull(expected);
}
Some of it, like the initialisation of the list and adding items to the list using the array is what I have added myself to try and figure out what to do.
If anyone can provide any help on how I could test this, I don't see how it can work with a list array.