Click here to Skip to main content
14,361,624 members
Rate this:
Please Sign up or sign in to vote.
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
Updated 8-Oct-19 23:53pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100