On the other hand, you will find the StringReader / Writer classes in System.IO. StringWriter , for example. implements TextWriter for the underlying StringBuilder .
Personally, I never used it, but if you have a program for writing text files, you can make it work with TextWriter . Then, in your test, instead of creating an instance of StreamWriter, you create an instance of StringWriter , after which you can check what was written by looking at the underlying StringBuilder .
Now I am dizzy ...
source share