title: waiting IObservable to get all elements error
body: <p>I have this class:</p>
  
  <pre><code>public class TestService
  {
       public IObservable&lt;int&gt; GetObservable(int max)
       {
           var subject = new Subject&lt;int&gt;();
           Task.Factory.StartNew(() =&gt;
                                 {
                                     for (int i = 0; i &lt; max; i++)
                                     {
                                         subject.OnNext(i);
                                     }
                                     subject.OnCompleted();
  
                                 });
           return subject;
       }
  }
  </code></pre>
  
  <p>I wrote a test method for this as well:</p>
  
  <pre><code>[TestMethod]
  public void TestServiceTest1()
  {
     var testService = new TestService();
     var i = 0;
     var observable = testService.GetObservable(3);
     observable.Subscribe(_ =&gt;
     {
        i++;
     });          
     observable.Wait();
     Assert.AreEqual(i, 3);
  }
  </code></pre>
  
  <p>But sometimes I get the error: <strong>Sequence contains no elements</strong> in method Wait().</p>
  
  <p>I propose that my IObservable is completed before test reaches the <em>observable.Wait()</em> line. 
  How can I avoid this error?</p>