I am trying to run a set of test cases through one of our internal applications. I need to be able to automate these tests and run them through the command line and log various things. The problem is that the existing code does not separate the view from the controller and throws MessageBoxes and Alerts everywhere that ask the user to click on a button (in my case just OK/CONTINUE). Currently, it has been decided to introduce state flags that will help determine the context from which the application is being run so one can decide whether to do a Console.WriteLine() or a MessageBox.Show(). But as you can imagine this has cascaded into a lot of changes and dirty if-else blocks.
Sadly, it doesn't look feasible to sit down and separate the logic from the view at this stage. So I was wondering if there was a way to detect the context in which the application is executing. I would like to replace each of the MessageBox() call with a Notify() call which itself can detect the context - whether to show the output on a command prompt or pop up a form.
EDIT_1: Any other suggestions for doing this are also welcome.