コード例 #1
0
        public void The_encrypted_serializer_should_be_awesome()
        {
            byte[] serializedMessageData;
            string key = "eguhidbehumjdemy1234567890123456";

            var serializer = new PreSharedKeyEncryptedMessageSerializer(key);

            using (var output = new MemoryStream())
            {
                serializer.Serialize(output, _message);

                serializedMessageData = output.ToArray();

                Trace.WriteLine(Encoding.UTF8.GetString(serializedMessageData));
            }

            var deserializer = new PreSharedKeyEncryptedMessageSerializer(key);

            using (var input = new MemoryStream(serializedMessageData))
            {
                var receivedMessage = deserializer.Deserialize(input) as SerializationTestMessage;

                Assert.AreEqual(_message, receivedMessage);
            }
        }
コード例 #2
0
        public void The_encrypted_serializer_should_be_awesome()
        {
            byte[] serializedMessageData;

            var serializer = new PreSharedKeyEncryptedMessageSerializer(_key, new TSerializer());

            using (var output = new MemoryStream())
            {
                serializer.Serialize(output, _message.ToSendContext());

                serializedMessageData = output.ToArray();

                //          Trace.WriteLine(Encoding.UTF8.GetString(serializedMessageData));
            }

            using (var input = new MemoryStream(serializedMessageData))
            {
                ReceiveContext receiveContext = ReceiveContext.FromBodyStream(input);
                serializer.Deserialize(receiveContext);

                IConsumeContext <PartialSerializationTestMessage> context;
                receiveContext.TryGetContext(out context).ShouldBeTrue();

                context.ShouldNotBeNull();

                context.Message.ShouldEqual(_message);
            }
        }
コード例 #3
0
        public void The_encrypted_serializer_should_be_awesome()
        {
            byte[] serializedMessageData;
            string key = "eguhidbehumjdemy1234567890123456";

            var serializer = new PreSharedKeyEncryptedMessageSerializer(key);

            using (var output = new MemoryStream())
            {
                serializer.Serialize(output, _message);

                serializedMessageData = output.ToArray();

                Trace.WriteLine(Encoding.UTF8.GetString(serializedMessageData));
            }

            var deserializer = new PreSharedKeyEncryptedMessageSerializer(key);

            using (var input = new MemoryStream(serializedMessageData))
            {
                var receivedMessage = deserializer.Deserialize(input) as SerializationTestMessage;

                Assert.AreEqual(_message, receivedMessage);
            }
        }