public void Basic_publishing_reaches_the_flexible_subscription() { var b = ConstructBusForHandle(); var handler = new SomeHandler(); b.Subscribe(handler); b.Publish(new MessageA()); handler.MsgACalls.ShouldBeEqualTo(1); }
public void publishing_method_subscription_correct_returns_known_instance() { var h = new SomeHandler(); var sb = new MethodScanner("Route").MakeBuilder(); var subs = sb.BuildSubscriptions(h).OfType<IKnowsSubscribedInstance>().ToList(); subs.ShouldHaveCount(1); subs.All(s => s.Instance.Equals(h)).ShouldBeTrue("Not all known instances are the correct one"); }
public void Subscriptions_for_publishing_method_based_work_correctly() { var handler = new SomeHandler(); var subscription = _builder.BuildSubscriptions(handler).First(); subscription.Push(new MessageB()); subscription.Handles(typeof(MessageB)).ShouldBeTrue(); handler.MsgBCalls.ShouldBeEqualTo(1); _bus.VerifyMessageIsOfType<MessageC>(); }
public void Subscriptions_for_object_method_based_work_correctly() { var builder = new MethodBasedBuilder("Handle"); var handler = new SomeHandler(); var subs = builder.BuildSubscriptions(handler); var subscription = subs.First(); subscription.Handles(typeof(MessageA)).ShouldBeTrue(); subscription.Push(new MessageA()); handler.MsgACalls.ShouldBeEqualTo(1); }
public void Disposal_Also_works_on_flexible_subscriptions() { var b = ConstructBusForHandle(); var handler = new SomeHandler(); var d = b.Subscribe(handler); b.Publish(new MessageA()); d.Dispose(); b.Publish(new MessageA()); handler.MsgACalls.ShouldBeEqualTo(1); }
public void Handler_may_accept_its_own_dispose_token() { var b = ConstructBusForHandle(); var handler = new SomeHandler(); b.Subscribe(handler); b.Publish(new MessageA()); handler.MsgACalls.ShouldBeEqualTo(1); handler.InvokeDisposeToken(); b.Publish(new MessageA()); handler.MsgACalls.ShouldBeEqualTo(1); }
public void Related_to_caching_resolver_failed_publish() { _bus.Publish(new MessageA()); _handler.MsgACalls.ShouldBeEqualTo(1); _handler.InvokeDisposeToken(); _handler = new SomeHandler(); _handler.MsgACalls.ShouldBeEqualTo(0); _bus.Subscribe(_handler); _bus.Publish(new MessageB()); _bus.Publish(new MessageA()); _handler.MsgACalls.ShouldBeEqualTo(1); }
public void Related_to_caching_resolver_failed_publish() { var b = ConstructBusForHandle(); var handler = new SomeHandler(); b.Subscribe(handler); b.Publish(new MessageA()); handler.MsgACalls.ShouldBeEqualTo(1); handler.InvokeDisposeToken(); handler = new SomeHandler(); handler.MsgACalls.ShouldBeEqualTo(0); b.Subscribe(handler); b.Publish(new MessageB()); b.Publish(new MessageA()); handler.MsgACalls.ShouldBeEqualTo(1); }
public void Given() { _bus = ConstructBusForHandle(); _handler = new SomeHandler(); _handlerDisposer = _bus.Subscribe(_handler); }
public When_Using_The_Bus_With_Flexible_Subscriptions() { _bus = ConstructBusForHandle(); _handler = new SomeHandler(); _handlerDisposer = _bus.Subscribe(_handler); }