title: How to test a stream in Dart
body: <p>How to test a stream in dart? I have this code:</p>
  
  <pre class="lang-dart prettyprint-override"><code>test('words are reading sequentially correct', () {
    WordTrackerInterface wordTracker = WordTracker.byContent('0 1 2');
    wordTracker.setWordsCountPerChunk(1);
    var stream = wordTracker.nextWordStringStream();
  
    expect(
        stream,
        emitsInOrder(List&lt;Word&gt;.generate(
            6, (i) =&gt; i &gt; 2 ? Word('') : Word(i.toString()))));
  
    for (int i = 0; i &lt; 6; i++) {
      wordTracker.nextWord();
    }
  });
  </code></pre>
  
  <p>I need to test that the member data <code>Word::content</code> which is a <code>String</code> is equal to that provided in the <code>emitsInOrder</code>.</p>
  
  <p>Something like the following for stream:</p>
  
  <pre class="lang-dart prettyprint-override"><code>expect(
      stream,
      emitsInOrder(List&lt;Word&gt;.generate(
          6, (i) =&gt; i &gt; 2 ? Word('') : Word(i.toString()))),
      expect((Word actual, Word expected) {
    return actual.content == expected.content;
  }));
  </code></pre>