protected override void DoSetUp()
        {
            sender = new Sender();
            receiver = new Receiver();
            transport = new EncryptionAndCompressionTransportDecorator(sender, receiver);

            Console.WriteLine(RijndaelHelper.GenerateNewKey());
        }
        static string GenerateRijndaelHelp()
        {
            return
                (string.Format(
                     @"To help you get started, here's a valid rijndael element, including a fresh and newly generated
key - and yes, I promise that it has been generated just this moment :) you can try running your app
again if you don't believe me.

    <rijndael key=""{0}""/>

The key has been generated with the biggest valid size, so it should be pretty secure.
",
                     EncryptionAndCompressionTransportDecorator.GenerateKeyBase64()));
        }
        /// <summary>
        /// Configures that message bodies should be encrypted/decrypted with the specified base 64-encoded key
        /// </summary>
        public static void EncryptMessageBodies(this DecoratorsConfigurer configurer, string keyBase64)
        {
            configurer.AddDecoration(b =>
            {
                var decorator = configurer
                                .Backbone
                                .LoadFromRegistry(() =>
                {
                    var instance      = new EncryptionAndCompressionTransportDecorator(b.SendMessages, b.ReceiveMessages);
                    b.SendMessages    = instance;
                    b.ReceiveMessages = instance;
                    return(instance);
                });

                decorator.EnableEncryption(keyBase64);
            });
        }
        /// <summary>
        /// Configures that message bodies should be encrypted/decrypted with the specified base 64-encoded key
        /// </summary>
        public static void EncryptMessageBodies(this DecoratorsConfigurer configurer, string keyBase64)
        {
            configurer.AddDecoration(b =>
                {
                    var decorator = configurer
                        .Backbone
                        .LoadFromRegistry(() =>
                            {
                                var instance = new EncryptionAndCompressionTransportDecorator(b.SendMessages, b.ReceiveMessages);
                                b.SendMessages = instance;
                                b.ReceiveMessages = instance;
                                return instance;
                            });

                    decorator.EnableEncryption(keyBase64);
                });
        }
        public void CanGenerateValidKey()
        {
            var key = EncryptionAndCompressionTransportDecorator.GenerateKeyBase64();

            var localInstance = new EncryptionAndCompressionTransportDecorator(sender, receiver)
                .EnableEncryption(key);

            var toSend = new TransportMessageToSend
            {
                Label = Guid.NewGuid().ToString(),
                Headers = new Dictionary<string, object>
                                               {
                                                   {Guid.NewGuid().ToString(), Guid.NewGuid().ToString()}
                                               },
                Body = Guid.NewGuid().ToByteArray(),
            };

            localInstance.Send("test", toSend, new NoTransaction());

            var receivedTransportMessage = sender.SentMessage.ToReceivedTransportMessage();

            receiver.SetUpReceive(receivedTransportMessage);

            var receivedMessage = localInstance.ReceiveMessage(new NoTransaction());

            receivedMessage.Label.ShouldBe(toSend.Label);
            var expectedHeaders = toSend.Headers.Clone();
            receivedMessage.Headers.ShouldBe(expectedHeaders);
            receivedMessage.Body.ShouldBe(toSend.Body);
        }