public void Never1() { string result = ""; var d = AsyncObservable.Never <int>() .Subscribe(i => result += i, ex => result += "E", () => result += "C"); d.Dispose(); result .Should().Be(""); }
public void Finally2() { string result = ""; _ = AsyncObservable.Never <int>() .Finally(() => result += "1") .Finally(() => result += "2") .SubscribeAsync(i => result += "N", ex => result += "E", () => result += "C"); result .Should().Be(""); }
public void Never1() { string result = ""; var cts = new CancellationTokenSource(); _ = AsyncObservable.Never <int>() .SubscribeAsync(i => result += i, ex => result += "E", () => result += "C", cts.Token); cts.Cancel(); result .Should().Be("E"); }
public async Task Finally1() { var cts = new CancellationTokenSource(); string result = ""; var t = AsyncObservable.Never <int>() .Finally(() => result += "1") .Finally(() => result += "2") .SubscribeAsync(i => result += "N", ex => result += "E", () => result += "C", token: cts.Token); cts.Cancel(); await t; result .Should().Be("12E"); }
public async Task Using2() { var cts = new CancellationTokenSource(); var result = ""; var t = AsyncObservable.Using(() => Disposable.Create(() => result += "3"), _ => AsyncObservable.Using(() => Disposable.Create(() => result += "2"), __ => AsyncObservable.Using(() => Disposable.Create(() => result += "1"), ___ => AsyncObservable.Never <Unit>()))) .Finally(() => result += "4") .SubscribeAsync(i => result += "N", ex => result += "E", () => result += "C", ca: cts.Token); cts.Cancel(); await t; result .Should().Be("1234"); }