From: Chris M. <ch...@cl...> - 2003-03-20 18:00:15
|
> I have problems to test dialog forms. I fudge this in my application. For things like MessageBox: I add in boolean properties to the forms that say things like "OverrideConfirmationDialog" and with it "OverrideConfirmationResponse". Then when I need a MessageBox, the production code does a switch -- if OverrideConfirmationDialog is false, it does the MessageBox, otherwise, no message box and go with the setting in OverrideConfirmationResponse. Then the testing code can control things. If I want to ensure that confirmation routine was called, then I add in production code that sets a third boolean (something like "ConfirmationDialogCalled") that the test code can verify. I don't like it because it still doesn't literally test the production case -- it just tests all around it, trusting that the production code that's never actually run in testing will be kept as simple as a single MessageBox call or somesuch. For dialogs that need to be ShowModal in production: I add in a switch (either conditional compile or simple boolean) that will call ShowModal in production and just Show in test. Again, I don't really like that solution, but it's worked out well so far. Chris |