Menu

#16 MessageBoxTester missing members

open
nobody
None
5
2010-06-20
2010-06-20
No

I think the MessageBoxTester could do with some new members. For example, the ability to retrieve the MessageBox's MessageBoxIcon, MessageBoxButtons, MessageBoxDefaultButton, and the DialogResult that it returns once one of its buttons has been clicked.

I also notice that while it has ClickOk and ClickCancel methods, there is no way to tell it to click the Yes, No, Abort, Cancel or Retry buttons. So if my test brings up a MessageBox which doesn't have a Cancel or OK button, either I need to click the button myself (if I've overridden the UseHidden property to return false) or my test hangs waiting for someone to click a button which nobody can see.

For an example of what I mean, take a look at http://commonforms.svn.sourceforge.net/viewvc/commonforms/CommonForms/CleverMessageBox.cs?revision=21&view=markup (the class being tested) and http://commonforms.svn.sourceforge.net/viewvc/commonforms/CommonForms.Example/NUnitTests/CleverMessageBoxTest.cs?revision=21&view=markup (the test fixture).

I've only just discovered this project and it looks like it can take a lot of the pain out of unit testing winforms classes. Keep up the good work :-)

Simon.

Discussion

  • lhab

    lhab - 2010-08-05

    Hi.

    You can click the other buttons using the SendCommand method. As for your other requests, I don't know if it can be done. I will look into it, but don't hold your breath.

     
  • Simon Bridewell

    Simon Bridewell - 2010-08-05

    Thank you lhab, I found the SendCommand method shortly after posting this feature request.

    I'm glad to see that people are still working on this project, and like you say, I'm not going to hold my breath for members to return the MessageBox's icon, buttons or result. It's a nice to have, and I'm sure you've got more important things to work on :-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.