winforms - Ignore Form.ShowDialog() when testing a button click event that pops up a form? -


i ask how test button click event want check results after having shown form. using nunit test. created extension method show form below,have tried different methods such checking debugger.isattached?;

    public static void showformdialog(this form form)     {         if(debugger.isattached)             form.showdialog();     } 

but appears still popup form while running test. there other way this?

your design might need work. testing ? form or class handles form events? if 2 not separated, should be.

if latter, should use dependency injection, can stub form, , raise event in own way.

using conditionals debugger.isattached should never used without extremely reasons (haven't seen enough reason yet).

regards, morten


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -