public void MessageSerializationException_should_be_thrown_on_exception_while_serializing_message()
        {
            var messageSerialization = new MessageSerialization();

            messageSerialization.RegisterSerializer(ExceptionTestMessage.TypeId, new ExceptionTestMessageSerializer());

            var messageThatCausesExceptionOnSerialization = new ExceptionTestMessage(true, false);
            var exception = Assert.Throws <MessageSerializationException>(() => messageSerialization.Serialize(messageThatCausesExceptionOnSerialization));

            Assert.IsInstanceOf <TestException>(exception.InnerException);
        }
        public void MessageDeserializationException_should_be_thrown_on_exception_while_deserializing_message()
        {
            var messageSerialization = new MessageSerialization();
            messageSerialization.RegisterSerializer(ExceptionTestMessage.TypeId, new ExceptionTestMessageSerializer());
            messageSerialization.RegisterDeserializer(ExceptionTestMessage.TypeId, new ExceptionTestMessageDeserializer());

            var messageThatCausesExceptionOnDeserialization = new ExceptionTestMessage(false, true);
            var message = messageSerialization.Serialize(messageThatCausesExceptionOnDeserialization);
            var exception = Assert.Throws<MessageDeserializationException>(() => messageSerialization.Deserialize(ExceptionTestMessage.TypeId, message));
            Assert.IsInstanceOf<TestException>(exception.InnerException);
        }