public void ProtoBufSerializationTest_2_DirectProtoBufNet() { var person = CreatePerson(); OtherPerson person2 = null; using (MemoryStream stream = new MemoryStream()) { Serializer.Serialize(stream, person); stream.Seek(0, SeekOrigin.Begin); person2 = Serializer.Deserialize <OtherPerson>(stream); } Assert.NotSame(person, person2); //The serializer returned an instance of the same object person.ShouldBeEquivalentTo(person2); }
protected OtherPerson CreatePerson() { var person = new OtherPerson { Id = 12345, Name = "Fred", Address = new Address { Line1 = "Flat 1", Line2 = "The Meadows" } }; return(person); }