Javaв„ў EE 5 Tutorial, The (3rd Edition)

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.

Категории