Do You Have a Test for That?


We wrote that customer test, and sure enough it didn t work. No surprise there. I was all for fixing it, but Chet asked, Should we write a failing programmer unit test first? Well, of course we should. So we looked at our SetInput method, the one that reads the input from the input stream and sets it into the TextModel. It goes like this:

 private void SetInput(StringReader reader) { 
String[] input = ArrayToEnd(reader);
model.Lines = input;
}

We figured it needed to go something like this:

 private void SetInput(StringReader reader) { 
String[] input = ArrayToEnd(reader);
model.Lines = CleanLines(input);
model.SelectionStart = CursorLocation(input);
}

CleanLines would return a new array of lines with the line containing the vertical bar fixed. And CursorLocation would return the cursor location by counting characters up to the vertical bar. No problem.




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

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