private static void CreationOps() { var ret = Observable.Return(3.14); Dump(ret); var range = Observable.Range(1, 5); Dump(range); var repeat = Observable.Repeat(range, 2); Dump(repeat); var starts = Observable.StartWith(Observable.Empty('z'), 's', 't', 'a', 'r', 't'); Dump(starts); var toObs = new[] { 1, 1, 2, 3, 5, 8, 13 }.ToObservable(); Dump(toObs); var timer = Observable.Timer(DateTime.Now + TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(0.2)).Take(10); Dump(timer); var defaultIfEmpty = Observable.DefaultIfEmpty(Observable.Empty(0), 555); Dump(defaultIfEmpty); var create = Observable.Create( (IObserver <string> observer) => { Console.Write("Subscribed. "); observer.OnNext("a"); observer.OnNext("b"); observer.OnCompleted(); Thread.Sleep(1000); return(Disposable.Create(() => Console.WriteLine("Unsubscribed."))); }); Dump(create); }
public void DefaultIfEmpty_ArgumentChecking() { ReactiveAssert.Throws <ArgumentNullException>(() => Observable.DefaultIfEmpty(default(IObservable <int>))); ReactiveAssert.Throws <ArgumentNullException>(() => Observable.DefaultIfEmpty(default, 42));