public async Task Finally6() { string result = ""; bool rethrown = false; try { await AsyncObservable.Empty <int>() .Finally(() => { result += "1"; throw new Exception(); }) .Finally(() => { result += "2"; throw new Exception(); }) .SubscribeAsync(); } catch { rethrown = true; } rethrown .Should().Be(true); result .Should().Be("12"); }
public async Task Empty() { var value = await AsyncObservable.Empty <int>().AllAsync(i => false); value .Should().Be(true); }
public async Task Empty() { var value = await AsyncObservable.Empty <int>().ToListAsync(); value .Should().HaveCount(0); }
public async Task Empty() { var value = await AsyncObservable.Empty <int>().AnyAsync(); value .Should().Be(false); }
public async Task EmptyWithPredicate() { var value = await AsyncObservable.Empty <int>().AnyAsync(i => i > 4); value .Should().Be(false); }
public void Count0() { Func <Task <int> > func = async() => await AsyncObservable.Empty <int>().FirstAsync(); func .Should().ThrowExactly <InvalidOperationException>(); }
public async Task Empty1() { string result = ""; await AsyncObservable.Empty <int>() .SubscribeAsync(i => result += i, ex => result += "E", () => result += "C"); result .Should().Be("C"); }
public async Task Int_Intermediate_Empty() { string result = ""; await AsyncObservable.Empty <int>() .Max(intermediateResults: true) .SubscribeAsync(i => result += i, onError: ex => result += "E", onCompleted: () => result += "C"); result .Should().Be("E"); }
public async Task Double_Empty() { var result = ""; await AsyncObservable.Empty <double>() .Max() .SubscribeAsync(i => result += i, onError: ex => result += "E", onCompleted: () => result += "C"); result .Should().Be("E"); }
public async Task Long_Empty() { string result = ""; await AsyncObservable.Empty <long>() .Max() .SubscribeAsync(i => result += i, onError: ex => result += "E", onCompleted: () => result += "C"); result .Should().Be("E"); }
public async Task Double_Intermediate_Empty() { double result = Double.NaN; await AsyncObservable.Empty <double>() .Sum(intermediateResults: true) .SubscribeAsync(i => result = i); result .Should().Be(Double.NaN); }
public async Task Double_Empty() { double result = 0.0; await AsyncObservable.Empty <double>() .Sum() .SubscribeAsync(i => result = i); result .Should().Be(0.0); }
public async Task Int_Empty() { string result = ""; await AsyncObservable.Empty <int>() .Sum() .SubscribeAsync(i => result += i, onCompleted: () => result += "C"); result .Should().Be("0C"); }
public async Task Empty() { string result = ""; await AsyncObservable.Empty <int>() .DistinctUntilChanged() .SubscribeAsync(i => result += i, onCompleted: () => result += "C"); result .Should().Be("C"); }
public async Task Int_Nullable_Empty() { string result = ""; await AsyncObservable.Empty <int?>() .Max() .SubscribeAsync(i => result += i == null ? "null" : i.ToString(), onError: ex => result += "E", onCompleted: () => result += "C"); result .Should().Be("nullC"); }
public async Task Finally3() { string result = ""; await AsyncObservable.Empty <int>() .Finally(() => result += "1") .Finally(() => result += "2") .SubscribeAsync(i => result += "N", ex => result += "E", () => result += "C"); result .Should().Be("12C"); }
public void ArgumentExceptions() { Func <Task> action; action = async() => await default(IAsyncObservable <int>).AllAsync(i => true); action .Should().Throw <ArgumentNullException>(); action = async() => await AsyncObservable.Empty <int>().AllAsync(null); action .Should().Throw <ArgumentNullException>(); }
public void ArgumentExceptions() { Func <IDisposable> funcR = null; Func <IDisposable, IAsyncObservable <int> > funcO = null; Action action; action = () => AsyncObservable.Using(funcR, _ => AsyncObservable.Empty <int>()); action .Should().Throw <ArgumentNullException>(); action = () => AsyncObservable.Using(() => new BooleanDisposable(), funcO); action .Should().Throw <ArgumentNullException>(); action = () => AsyncObservable.Using(funcR, funcO); action .Should().Throw <ArgumentNullException>(); }