title: How does protectAsyncN work in Dart unittest package?
body: <p>I really don't understand the purpose of protectAsyncN methods.</p>
  
  <p>Could someone please explain me how should it work? For example, imagine following test case:</p>
  
  
  
  <pre class="lang-dart prettyprint-override"><code>import "package:unittest/unittest.dart";
  import "dart:async";
  
  void main() {
    test("Protect async", () {
      // given
      var controller = new StreamController();
  
      // when
      controller.add("This is correct!");
  
      // then
      controller.stream.listen(protectAsync1((event) {
        expect(event, equals("This is correct!"));
      }));
    });
  }
  </code></pre>
  
  <p>What should the behavior be? I would expect this test case to pass, however I get the following message:</p>
  
  <pre class="lang-dart prettyprint-override"><code>unittest-suite-wait-for-done
  ERROR: Protect async
    Callback called (1) after test case Protect async has already been marked as pass.
  
  0 PASSED, 0 FAILED, 1 ERRORS
  Unhandled exception:
  Exception: Some tests failed.
  #0      SimpleConfiguration.onDone (package:unittest/src/simple_configuration.dart:213:9)
  #1      _completeTests (package:unittest/unittest.dart:779:17)
  #2      _runTest (package:unittest/unittest.dart:734:19)
  #3      _nextTestCase (package:unittest/unittest.dart:641:11)
  #4      _asyncRunCallback (dart:async/schedule_microtask.dart:18)
  #5      _asyncRunCallback (dart:async/schedule_microtask.dart:21)
  #6      _createTimer.&lt;anonymous closure&gt; (dart:async-patch/timer_patch.dart:11)
  #7      _Timer._createTimerHandler._handleTimeout (timer_impl.dart:151)
  #8      _Timer._createTimerHandler._handleTimeout (timer_impl.dart:159)
  #9      _Timer._createTimerHandler._handleTimeout (timer_impl.dart:159)
  #10     _Timer._createTimerHandler.&lt;anonymous closure&gt; (timer_impl.dart:166)
  #11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:93)
  </code></pre>
  
  <p>I have tried using guardAsync and it works as expected. However, I really don't understand protectAsync.</p>
  
  <p>Could someone explain me the purpose and correct usage of it? Thanks a lot!</p>