I like the suggestion here:
It suggests using this code:
public class SettingsReader()
{
public SettingsReader(System.IO.StreamReader reader)
{
// read contents of stream...
}
}
// In production code:
new SettingsReader(new StreamReader(File.Open("settings.xml")));
// In unit test:
new SettingsReader(new StringReader("<settings>dummy settings</settings>"));
I am just wondering what the best practice is to 'supply' large test strings (i.e. several lines of the file to be parsed).