Test from a File


Since we re trying to write a customer test here, we envision that the customer will give us little scripts, like the one in StringInput, in files. We created a file by pasting the StringInput data into a text file, and we wrote this new test:

 [Test] public void FileInput() { 
StreamReader stream = File.OpenText("c:\data\csharp\notepad
\fileInput.txt");
String contents = stream.ReadToEnd();
stream.Close();
InterpretCommands(contents);
}

We had to look up some file stuff, because we haven t done much file reading, but the test above worked the first time. Sophisticated C#ers will notice that we didn t use the @ string technique to avoid doubling those backslashes. That s because we didn t know it. I just read about it last night, and I promise to use it in the future.




Extreme Programming Adventures in C#
Javaв„ў EE 5 Tutorial, The (3rd Edition)
ISBN: 735619492
EAN: 2147483647
Year: 2006
Pages: 291

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net