Learn how to write the code to read text from a file, and note that the code for parsing a line of text is not changed thanks to the use of the TextReader base class.
- [Instructor] We've previously written the code…to read an individual line of text…and parse the values in the columns…into the data types we expect.…Now, let's try to do that for the entire file.…So let's go to our unit test file, Tests_WeatherData,…and we scroll down.…We find our unit test that's named ParseSampleText.…Now, in this case, please note, there is a variable…called sampleData, select it, press F12.…And you'll see at the top of the file…there are multiple lines of text pasted into a variable.…
The idea is again to have a deterministic unit test,…and so what's going to happen is…we're going to test using this hard coded string,…so that it is deterministic and fast in our unit tests,…and then we will expand the unit test…to actually read from a file.…Let's scroll back down to our unit test.…And so the first one is ParseSampleText here on line 50.…And text here is going to use a StringReader type…to read from our built-in hard coded string…one line of text at a time.…
And we already know the first line of text is just a header,…
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
Next steps2m 46s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.