비동기 적으로 실행되는 개발 한 라이브러리에 라이브러리 함수가 있습니다. 예 하여 설명 : FUNC1 즉시 라이브러리의 일부의 처리를 개시하고유닛 비동기 메서드 테스트 .NET 4.0 스타일
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);
}
반환.
결과는 처리이다 대리자
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);
}
그래서 여기
질문은 통해 이벤트로 클라이언트에 도착 : 가 어떻게 이것에 대한 단위 테스트를 작성합니까?
이것을 확인하는 것이 좋습니다. http://stackoverflow.com/questions/15207631/how-to-write-unit-test-cases-for-async-methods –