Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if that possible or not, easy or not ? how can I write Unit test for event like Button
in this code i have a button which should create an invoice one i click it and I would like to write unit test .

What I have tried:

protected void CreateBranchInvoice_Click(object sender, EventArgs e)

{
doing some logic here
}
Posted
Updated 8-Oct-19 22:53pm

1 solution

If there is a lot of code in the event then move the code to a function and have the event call the function. You can then write a unit test for the function. Note that things have to be written with unit testing in mind, you can't always retro-fit unit tests without changing the code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900