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
bubbleuiexceptionwhenthis.initiaterecording()called - force
exceptionnotbubbleuiexceptionwhenthis.initiaterecording()called - wrap
messagebox.showcan test prints expect when exceptions thrown. - test
objlog.errorcalled.
you can assume click event works (that method called when control clicked) microsoft have tested this.
Comments
Post a Comment