How to unit test (in C#) that a button is clicked?

后端 未结 2 1872
小蘑菇
小蘑菇 2021-01-22 12:23

I have a user control that has button whose click event handler contains the core logic. I want to test this button click handler. This handler function calls a public function

2条回答
  •  孤独总比滥情好
    2021-01-22 13:06

    You can write a method that programmatically raises the Click event and call that from your unit test.

    Edit: Ah, this actually exists already: http://msdn.microsoft.com/en-us/library/hkkb40tf(VS.90).aspx

提交回复
热议问题