public void Should_be_able_to_get_subscribed_to_events() { Event1 capturedEvent = null; eventBus.Subscribe <Event1>(@event => capturedEvent = @event); var publishedEvent = new Event1 { Text = "Hello World" }; eventBus.Publish(publishedEvent); capturedEvent.ShouldNotBeNull(); capturedEvent.ShouldBeTheSameAs(publishedEvent); }
public void Should_handle_resubscription_from_handler() { Event1 eventFromSubscription = null; eventBus.Subscribe <Event1>(@event => { eventFromSubscription = @event; eventBus.Subscribe <Event1>(x => { }); }); var publishedEvent1 = new Event1 { Text = "Hello World" }; eventBus.Publish(publishedEvent1); eventFromSubscription.ShouldNotBeNull(); }
public void Should_handle_cancelation_from_handler() { Event1 eventFromSubscription = null; CancelSubscription cancelEvent = null; cancelEvent = eventBus.Subscribe <Event1>(@event => { cancelEvent(); eventFromSubscription = @event; }); var publishedEvent1 = new Event1 { Text = "Hello World" }; eventBus.Publish(publishedEvent1); eventFromSubscription.ShouldNotBeNull(); }