Unit Testing Buttons in C# - .NET Visual Studio -


i have windows form application bunch of buttons. want able test them button1.performclick(); in unit test class.

is there anyway without creating method each button inside main program like: public void testbutton1click(){ button1.performclick(); }

for reason button variables don't show in context of unit test. appreciated, thanks

yeah buttons not ordinarily available unit test because automatically private (changing them in designer internal work... until compile).

a minimally-invasive , viable option use fakes (https://msdn.microsoft.com/en-us/library/hh549175.aspx) know of them , haven't used them.

how test winforms buttons use humble object pattern (http://xunitpatterns.com/humble%20object.html) , logic have been in buttons in separate object can test. buttons call object. if code gets complicated sorts of visual updates do, rudimentary turn mvp architecture @ point.


Comments