/// <summary>
 /// Enforce messaging rules. Make sure, the message can be used by Bus.Reply.
 /// </summary>
 /// <param name="messages">Collection of messages to enforce messaging rules on.</param>
 public static void AssertIsValidForReply(IEnumerable <object> messages)
 {
     if (messages.Any(m => MessageConventionExtensions.IsCommand(m) || MessageConventionExtensions.IsEvent(m)))
     {
         throw new InvalidOperationException(
                   "Reply is neither supported for Commands nor Events. Commands should be sent to their logical owner using bus.Send and bus. Events should be Published with bus.Publish.");
     }
 }
            public void Should_cache_the_message_convention()
            {
                var timesCalled = 0;

                MessageConventionExtensions.IsCommandTypeAction = t =>
                {
                    timesCalled++;
                    return(false);
                };

                MessageConventionExtensions.IsCommand(this);
                Assert.AreEqual(1, timesCalled);

                MessageConventionExtensions.IsCommand(this);
                Assert.AreEqual(1, timesCalled);
            }