I am having a class which uses the XmlReader and XmlReaderSettings classes in C# to validate Xml files against a schema. Since my application involves reading the Xml data from the database, I decide to show an error to the user in a MessageBox. Thus, any validating errors as well as any exceptions thrown would be shown with a string "Error occurred while parsing" appearing in a MessageBox.
I also have a boolean variable which returns whether the parsing was successful or not.
Right now, I am using the boolean value returned by the Parse function in an Assert while having the parse function parse both valid and invalid Xml files.
Thus, while running the suite of test cases, I have these stack of message boxes piled up in the other window.
The real question I had that was it ok to have a number of these message boxes pop up while the unit testing framework in Visual Studio tells us whether all the tests passed or not.
Or is it a case where I just need to return a bool value and then the GUI class displays the appropriate error message.
Q2. Also, say If i do need to check whether a particular string was parsed correctly and stored into an array, can I subclass the main class to add some functionality which could help me in better write Unit tests?
I would really appreciate some suggestions as to how my design and unit testing should be.
Also, I do accept that I am making a big mistake in writing the Unit tests after I have written down the class which I need to test and I know it should be the other way round.