public void GetResult_Empty() { var s = new AsyncSubject <int>(); s.OnCompleted(); ReactiveAssert.Throws <InvalidOperationException>(() => s.GetResult()); }
/// <summary> /// Gets the result produced by the observable sequence. /// </summary> /// <returns>The result produced by the observable sequence.</returns> public T GetResult() { if (_subject != null) { return(_subject.GetResult()); } _exception.ThrowIfNotNull(); return(_result); }
/// <summary> /// Gets the result produced by the observable sequence. /// </summary> /// <returns>The result produced by the observable sequence.</returns> public T GetResult() { if (_subject != null) { return(_subject.GetResult()); } _exception?.Throw(); return(_result !); }
public void Dispose() { if (subject.IsCompleted) { var disposable = subject.GetResult(); if (disposable != null) { disposable.Dispose(); } } subject.Dispose(); }
private void GetResult_Blocking_Throw(AsyncSubject <int> s) { Assert.IsFalse(s.IsCompleted); var e = new ManualResetEvent(false); var ex = new Exception(); new Thread(() => { e.WaitOne(); s.OnError(ex); }).Start(); var y = default(Exception); var t = new Thread(() => { try { s.GetResult(); } catch (Exception ex_) { y = ex_; } }); t.Start(); while (t.ThreadState != ThreadState.WaitSleepJoin) { ; } e.Set(); t.Join(); Assert.AreSame(ex, y); Assert.IsTrue(s.IsCompleted); }
private void GetResult_Blocking(AsyncSubject <int> s) { Assert.IsFalse(s.IsCompleted); var e = new ManualResetEvent(false); new Thread(() => { e.WaitOne(); s.OnNext(42); s.OnCompleted(); }).Start(); var y = default(int); var t = new Thread(() => { y = s.GetResult(); }); t.Start(); while (t.ThreadState != ThreadState.WaitSleepJoin) { ; } e.Set(); t.Join(); Assert.AreEqual(42, y); Assert.IsTrue(s.IsCompleted); }
private void GetResult_Blocking_Throw(AsyncSubject<int> s) { Assert.IsFalse(s.IsCompleted); var e = new ManualResetEvent(false); var ex = new Exception(); new Thread(() => { e.WaitOne(); s.OnError(ex); }).Start(); var y = default(Exception); var t = new Thread(() => { try { s.GetResult(); } catch (Exception ex_) { y = ex_; } }); t.Start(); while (t.ThreadState != ThreadState.WaitSleepJoin) ; e.Set(); t.Join(); Assert.AreSame(ex, y); Assert.IsTrue(s.IsCompleted); }
private void GetResult_Blocking(AsyncSubject<int> s) { Assert.IsFalse(s.IsCompleted); var e = new ManualResetEvent(false); new Thread(() => { e.WaitOne(); s.OnNext(42); s.OnCompleted(); }).Start(); var y = default(int); var t = new Thread(() => { y = s.GetResult(); }); t.Start(); while (t.ThreadState != ThreadState.WaitSleepJoin) ; e.Set(); t.Join(); Assert.AreEqual(42, y); Assert.IsTrue(s.IsCompleted); }
public void GetResult_Empty() { var s = new AsyncSubject<int>(); s.OnCompleted(); ReactiveAssert.Throws<InvalidOperationException>(() => s.GetResult()); }