public void SerializeObject()
        {           
            var chuck = new People { Id = 1, Firstname = "chuck", Lastname = "norris" };
            
            var outputMessage = new StubHttpOutputMessage();

            converter.Write(chuck, ProtobufNetHttpMessageConverter.PROTO_MEDIATYPE, outputMessage);

            Assert.NotNull(outputMessage.Body);
            
            MemoryStream actual = new MemoryStream();
            byte[] expected = File.ReadAllBytes("people.data");
          
            outputMessage.Body(actual);

            Assert.AreEqual(expected, actual.ToArray());
        }
        public void GenerateSerializedVersions()
        {
            People[] peoples = new People[] 
            { 
                new People{ Id= 1, Firstname = "chuck", Lastname ="norris"},
                new People{ Id= 2, Firstname = "jackie", Lastname ="chan"},
                new People{ Id= 3, Firstname = "jean-claude", Lastname ="van damme"}
            };

            using(var fs = new FileStream("peopleList.data", FileMode.Create))
            {
                foreach(var item in peoples)
                {
                    Serializer.SerializeWithLengthPrefix(fs, item, PrefixStyle.Base128);
                }
            }

            using (var fs = new FileStream("people.data", FileMode.Create))
            {
                var chuck = new People { Id = 1, Firstname = "chuck", Lastname = "norris" };

                Serializer.Serialize<People>(fs, chuck);
            }
        }
        public void DeserializeObject()
        {
            var chuck = new People { Id = 1, Firstname = "chuck", Lastname = "norris" };

            var inputMessage = new StubHttpInputMessage();
            inputMessage.Body = new MemoryStream(File.ReadAllBytes("people.data"));

            People actual = converter.Read<People>(inputMessage);

            Assert.NotNull(actual);

            Assert.AreEqual(chuck, actual);
        }
        public void DeserializeObjectArray()
        {
            People[] peoples = new People[] 
            { 
                new People{ Id= 1, Firstname = "chuck", Lastname ="norris"},
                new People{ Id= 2, Firstname = "jackie", Lastname ="chan"},
                new People{ Id= 3, Firstname = "jean-claude", Lastname ="van damme"}
            };

            var inputMessage = new StubHttpInputMessage();
            inputMessage.Body = new MemoryStream(File.ReadAllBytes("peopleList.data"));

            var actual = converter.Read<People[]>(inputMessage);

            Assert.NotNull(actual);
            CollectionAssert.AreEqual(peoples, actual);
        }
        public void SerializeObjectArray()
        {
            People[] peoples = new People[] 
            { 
                new People{ Id= 1, Firstname = "chuck", Lastname ="norris"},
                new People{ Id= 2, Firstname = "jackie", Lastname ="chan"},
                new People{ Id= 3, Firstname = "jean-claude", Lastname ="van damme"}
            };

            var outputMessage = new StubHttpOutputMessage();

            converter.Write(peoples, ProtobufNetHttpMessageConverter.PROTO_MEDIATYPE, outputMessage);

            Assert.NotNull(outputMessage.Body);

            MemoryStream actual = new MemoryStream();
            byte[] expected = File.ReadAllBytes("peopleList.data");

            outputMessage.Body(actual);

            Assert.AreEqual(expected, actual.ToArray());
        }