I'm looking to unit test this method but not sure how to go about doing that with a Stream reader and array created in the method. Any ideas?
public static List<Associations> CollectingAssociations(StreamReader sr, string MainUID, string AssocTrainUID, string AssocLoc) {
string line;
List<Associations> associationsArray = new List<Associations>();
//skips the header
sr.ReadLine();
//reads top of the file, association records
while((line = sr.ReadLine()).Substring(0, 2) == "AA") {
if (line.Substring(3, 6).Contains(MainUID) &&
line.Substring(9, 6).Contains(AssocTrainUID) &&
line.Substring(37,7).Contains(AssocLoc)) {
associationsArray.Add(new Associations(line));
}
}
return associationsArray;
}
Aucun commentaire:
Enregistrer un commentaire