public void PushDoesNotBreakCallerIfConsumerThrows() { MockUES mock = fixture.Mock(); UnifiedEventSource es = mock.Instance; es.Subscribe(@event => throw new Exception("Oops")); es.Push(new Event()); }
public async Task PushDoesNotBreakCallerIfConsumerThrowsAsync() { MockUES mock = fixture.Mock(); UnifiedEventSource es = mock.Instance; es.SubscribeTask(@event => throw new Exception("Oops")); await es.PushAsync(new Event()); }
public void IfThrowsThenNotifyIsCalled() { Exception e = new Exception("Oops"); MockUES mock = fixture.Mock(); mock.Instance.Subscribe(@event => throw e); mock.Instance.Push(new Event()); mock.Notifier.Verify(x => x.Notify(e)); }
public async Task IfThrowsThenNotifyIsCalledAsync() { Exception e = new Exception("Oops"); MockUES mock = fixture.Mock(); mock.Instance.SubscribeTask(@event => throw e); await mock.Instance.PushAsync(new Event()); mock.Notifier.Verify(x => x.Notify(e)); }
public void IfConsumerThrowsContinueCallingConsumers() { MockUES mock = fixture.Mock(); UnifiedEventSource es = mock.Instance; bool called = false; es.Subscribe(@event => throw new Exception("Oops")); es.Subscribe(@event => called = true); es.Push(new Event()); Assert.True(called); }
public async Task AsyncAllCallbacksAreBeingCalledOnPush() { MockUES mock = fixture.Mock(); UnifiedEventSource es = mock.Instance; var calledCallbacks = new[] { false, false, false }; es.Subscribe(@event => calledCallbacks[0] = true); es.Subscribe(@event => calledCallbacks[1] = true); es.Subscribe(@event => calledCallbacks[2] = true); await es.PushAsync(new Event()); Assert.All(calledCallbacks, Assert.True); }
public async Task IfConsumerThrowsContinueCallingConsumersAsync() { MockUES mock = fixture.Mock(); UnifiedEventSource es = mock.Instance; bool called = false; es.SubscribeTask(@event => throw new Exception("Oops")); es.SubscribeTask(@event => Task.Run(() => called = true)); await es.PushAsync(new Event()); Assert.True(called); }
public async Task AsyncAllTaskCallbacksAreBeingCalledOnPush() { var tasks = Enumerable.Range(0, 5000).Select(async x => { MockUES mock = fixture.Mock(); UnifiedEventSource es = mock.Instance; var calledCallbacks = new[] { false, false, false }; es.SubscribeTask(@event => Task.Run(() => calledCallbacks[0] = true)); es.SubscribeTask(@event => Task.Run(() => calledCallbacks[1] = true)); es.SubscribeTask(@event => Task.Run(() => calledCallbacks[2] = true)); await es.PushAsync(new Event()); Assert.All(calledCallbacks, Assert.True); mock.Notifier.Verify((n) => n.Notify(It.IsAny <Exception>()), Times.Never(), ""); }); await Task.WhenAll(tasks); }