public void Subscriptions_are_built_for_object_method_based()
 {
     var builder = new MethodScanner("Handle").MakeBuilder();
     var subs = builder.BuildSubscriptions(new SomeHandler());
     subs.ShouldNotBeNull();
     subs.ShouldHaveCount(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_object_method_based_work_correctly()
 {
     var builder = new MethodScanner("Handle").MakeBuilder();
     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 Adapter_subscriptions_can_also_be_disposed()
        {
            var b = new MethodScanner("Handle").MakeBuilder();
            var disposableSub = new DisposableSubscription(b.BuildSubscriptions(new SomeHandler()).First());
            ISubscriptionResolver resolver = new CompositeSubscription();
            resolver.Add(disposableSub);

            var subs = resolver.GetSubscriptionsFor(new MessageA());
            subs.ShouldHaveCount(1);

            disposableSub.GetDisposer().Dispose();

            subs = resolver.GetSubscriptionsFor(new MessageA());
            subs.ShouldHaveCount(0);
        }