public void an_error_in_the_callback_does_not_propergate_to_the_caller() { var sub = new LabelSubscription(); Action <Message> callback = msg => { throw new InvalidOperationException(); }; sub.Subscribe("hello", callback); var expected = new Message { Label = "hello" }; sub.Dispatch(expected); Assert.Pass(); }
public void can_dispatch(string subscriptionLabel, string msgLabel) { var sub = new LabelSubscription(); Message actual = null; Action <Message> callback = msg => actual = msg; sub.Subscribe(subscriptionLabel, callback); var expected = new Message { Label = msgLabel }; sub.Dispatch(expected); Assert.AreEqual(expected, actual); }
public void an_error_in_a_callback_does_not_prevent_other_callbacks_from_being_called() { var sub = new LabelSubscription(); bool got = false; Action <Message> callback1 = msg => { throw new InvalidOperationException(); }; Action <Message> callback2 = msg => { got = true; }; sub.Subscribe("hello", callback1); sub.Subscribe("hello", callback2); var expected = new Message { Label = "hello" }; sub.Dispatch(expected); Assert.AreEqual(true, got); }