I have library functions in the library that I developed that execute asynchronously. Description by example:
private void Init()
{
// subscribe to method completion event
myLib.CompletionEvent += myLib_CompletionEvent;
}
private void MyButton1_Click(object sender, EventArgs e)
{
// start execution of Func1
myLib.Func1(param1, param2);
}
the Func1 initiates some processing in the library and immediately returns.
The result is of the processing arrives to the client as an event through a delegate
void myLib_CompletionEvent(ActionResult ar)
{
// ar object contains all the results: success/failure flag
// and error message in the case of failure.
Debug.Write(String.Format("Success: {0}", ar.success);
}
So here is the question: How do I write Unit test for this?