public void AgentCanHandleMultipleDisposeCalls() { Exception exception = null; var tcs = new TaskCompletionSource <bool>(); var agent = new ReactiveAsyncAgent <int, int>( initialState: 0, messageHandler: (state, msg, ct) => { return(Task.FromResult(state + 1)); }, errorHandler: (ex, ct) => Task.FromResult(true)); try { agent.Dispose(); agent.Dispose(); agent.Send(1); } catch (Exception ex) { exception = ex; } Assert.Null(exception); }
public async Task AgentSignalsCompleted() { var tcs = new TaskCompletionSource <bool>(); var agent = new ReactiveAsyncAgent <string, string>( initialState: string.Empty, messageHandler: (state, msg, ct) => { return(Task.FromResult(msg)); }, errorHandler: (ex, ct) => Task.FromResult(true)); agent.State.Subscribe(_ => { }, () => tcs.SetResult(true)); agent.Dispose(); var isCompleted = await tcs.Task; Assert.True(isCompleted); }