Button click

  • Thread starter Thread starter Davis
  • Start date Start date
D

Davis

Hi, I'm writing a little test app to simulate button clicks
to save me doing it myself. I've read the archives and easiest
way seems to be calling the event handler but i have a problem

Code below:

In my test harness i have
Form1 frm = new Form1();

frm.Show();

frm.button1_Click(this, EventArgs.Empty);

The problem i have is the button1_Click method is private in the class

i'm testing, how can i call my event handler. MouseEvent (another way of
doing all of this

seems to be overkill for what i'm trying to do).

Thanks
 
Expose a function from the form that runs the tests you want, or expose
each test so you can call them externally.

frm.Show();
frm.RunTests();

or

frm.Show();
frm.PressButton1();
frm.PressButton2();

Yes its cumbersome - however you might want to move the processing from
the event handlers directly and put them in private functions - which
can now be called from several locations, including event handlers.

--
I hope this helps

--
Norman Rericha
Senior Software Engineer
Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member
 
Back
Top