public void ToObservable2() { var lst = new List <int>(); var fail = false; var evt = new ManualResetEvent(false); var xs = Return42.ToObservable(); xs.Subscribe(new MyObserver <int>( x => { lst.Add(x); }, ex => { fail = true; evt.Set(); }, () => { evt.Set(); } )); evt.WaitOne(); Assert.False(fail); Assert.True(lst.SequenceEqual(new[] { 42 })); }
public async Task IgnoreElements2Async() { var xs = Return42.IgnoreElements(); var e = xs.GetAsyncEnumerator(); await NoNextAsync(e); }
public async Task Finally2Async() { var b = false; var xs = Return42.Finally(() => { b = true; }); var e = xs.GetAsyncEnumerator(); Assert.False(b); await HasNextAsync(e, 42); Assert.False(b); await NoNextAsync(e); Assert.True(b); }
public void ToEnumerable_Single() { var xs = Return42.ToEnumerable(); Assert.True(xs.SequenceEqual(new[] { 42 })); }