public void UnsubscribeTest()
        {
            var handler = Substitute.For <IHandle <TestMessage> >();

            var pubSub = new TopicBasedPubSub();

            pubSub.SubscribeByType(handler);
            pubSub.UnsubscribeByType(handler);

            pubSub.Publish(new TestMessage());

            handler.DidNotReceive().Handle(Arg.Any <TestMessage>());
        }
        public void PublishWhenPublishingTest()
        {
            var handler1 = Substitute.For <IHandle <TestMessage> >();
            var handler2 = Substitute.For <IHandle <TestMessage> >();

            var pubSub = new TopicBasedPubSub();

            handler1
            .When(x => x.Handle(Arg.Any <TestMessage>()))
            .Do(callInfo =>
            {
                Assert.DoesNotThrow(() => pubSub.UnsubscribeByType(handler1));
            });

            pubSub.SubscribeByType(handler1);
            pubSub.SubscribeByType(handler2);
            pubSub.Publish(new TestMessage());

            handler2.Received().Handle(Arg.Any <TestMessage>());
        }