title: Integrating NUnit to test asynchronous web services in windows phone 7
body: <p>I am trying to integrate NUnit in my windows phone project to test asynchronous web service calls. I am referring to NUnitTestRunnerWP7 dll. Here is what I did.</p>
  
  <p>But the asynchronous callback method is called after the Assert statement, hence it does not work. How can I execute the Assert after my callback? If I write the failed Assertion in callback, my application crashes.</p>
  
  <pre><code>[Test]
  public void TestAsyncFunc(){
          string result;
          ManualResetEvent manualReset = new ManualResetEvent(false);
          MyWebServiceClient client = GetMyWebServiceClient(); //added a service reference for asmx services
          client.LoginCompleted += delegate(object sender, EventArgs args)
          {
              result = args.Result.ToString();
              manualReset.Set();
          };
          client.LoginAsync("username", "password");
          if (!manualReset.WaitOne(5000))
              Assert.Fail();
  
          Assert.AreEqual("", result);
      }
  </code></pre>
  
  <p>I don't understand what am I missing. Any help would be appreciated.</p>
  
  <p>Thanks in advance. </p>