I'm writing a class that exports data to a CSV file, and its constructor takes in a TextWriter. The reason I'm using a TextWriter rather than a StreamWriter is so that it would make testing easier: I can use the same constructor for writing to a StreamWriter (which writes to files, the intended use-case) and to write to a StringWriter (which is useful for testing).
In my constructor I would like to perform some validation on the passed in TextWriter. The problem is I can't seem to figure out how to check if the TextWriter is open or closed. It's possible for StreamWriter if the BaseStream property is null. TextWriter does not have this property however. Is there another way of checking if a TextWriter is open or not?