public void CanSerializeAndBack()
        {
            var message = new MessageWithArray(Guid.NewGuid(), new[] { 1234, 5323 });

            var result = ExecuteSerializer.ForMessage<MessageWithArray>(message);

            Assert.IsNotNull(result.SomeInts);
            Assert.That(result.SomeInts, Has.Length.EqualTo(2));
            Assert.AreEqual(1234, result.SomeInts[0]);
            Assert.AreEqual(5323, result.SomeInts[1]);
        }
Esempio n. 2
0
        public void CanSerializeAndBack()
        {
            var message = new MessageWithArray(Guid.NewGuid(), new[] { 1234, 5323 });

            var result = ExecuteSerializer.ForMessage <MessageWithArray>(message);

            Assert.IsNotNull(result.SomeInts);
            Assert.That(result.SomeInts, Has.Length.EqualTo(2));
            Assert.AreEqual(1234, result.SomeInts[0]);
            Assert.AreEqual(5323, result.SomeInts[1]);
        }
        public void CanSerializeAndBack()
        {
            var serializer = new MessageSerializer
            {
                MessageMapper = new MessageMapper(),
                MessageTypes = new List<Type> { typeof(MessageWithArray) }
            };

            var message = new MessageWithArray(Guid.NewGuid(), new int[] { 1234, 5323 });

            var stream = new MemoryStream();
            serializer.Serialize(new object[] { message }, stream);

            stream.Position = 0;

            var messages = serializer.Deserialize(stream);

            Assert.NotNull(messages);
            Assert.That(messages, Has.Length.EqualTo(1));

            Assert.That(messages[0], Is.TypeOf(typeof(MessageWithArray)));
            var m = (MessageWithArray)messages[0];

            Assert.IsNotNull(m.SomeInts);
            Assert.That(m.SomeInts, Has.Length.EqualTo(2));
            Assert.AreEqual(1234, m.SomeInts[0]);
            Assert.AreEqual(5323, m.SomeInts[1]);
        }