Writing msUnit tests for asynchronous procedures

If you call the Start()-Method of a MyClass-Object the Object will start sending data with the DataEvent.

class MyClass {

    // Is called everytime new Data comes
    public event DataEventHandler DataEvent;

    // Starts de Data Process
    public void StartDataDelivery()


How do I write a Test for that functionality if i can Guarantee that the DataEvent will be Invoked at least three times during a fix time period.

I haven't done any asynchronous Unittests yet. How is that done, assuming that someone else needs to understand the test later?


MSTest hasn't had any serious updates for some time and I don't see that changing.

I'd strongly recommend moving to xUnit. It supports async tests (just return a Task from the test and await to your heart's content), and is used by many new Microsoft projects.

Need Your Help

Determining labels from another partial class/windows form

c# visual-studio-2010 class label

I'm bit new at this so excuse me if my question is a bit novice. I'm designing a Windows form application to basically replace an old excel spreadsheet then email system(not that its much of a syst...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.