Unit Testing forms and Events in c# -
i want write test cases c# code triggers events or displays form user input e.g.:
private void createrecord_click(object sender, eventargs e) { try { this.initiaterecording(); } catch (bubbleuiexception ex) { objlog.error(textres.idc_eshuttleerror, ex); messagebox.show( ex.message, textres.idc_eshuttleerror, messageboxbuttons.ok, messageboxicon.error); } catch (exception ex) { objlog.error("error occurred", ex); messagebox.show( ex.message, textres.idc_error, messageboxbuttons.ok, messageboxicon.error); } }
how write unit tests these kind of code using mbunit?
test:
this.initiaterecording()
called- force
bubbleuiexception
whenthis.initiaterecording()
called - force
exception
notbubbleuiexception
whenthis.initiaterecording()
called - wrap
messagebox.show
can test prints expect when exceptions thrown. - test
objlog.error
called.
you can assume click event works (that method called when control clicked) microsoft have tested this.
Comments
Post a Comment