예제 #1
0
        public void should_correctly_serialize_dynamic_data_with_binary()
        {
            var model      = SerializationTestHelper.GeneratePopulatedDynamicTypesModel();
            var serializer = new BinarySerializer(_mappingRegistry);

            var output = serializer.Serialize(model);

            testOutputHelper.WriteLine("FileSize: " + output.AsString.Length + " bytes");
            testOutputHelper.WriteLine(BitConverter.ToString(output.AsBytes));

            var deserializer = new BinaryDeserializer(_mappingRegistry, _typeCreator);
            var result       = deserializer.Deserialize <DynamicTypesModel>(output);

            SerializationTestHelper.AssertPopulatedDynamicTypesData(model, result);
        }
예제 #2
0
        public void should_correctly_serialize_dynamic_data_into_existing_object_with_json()
        {
            var model      = SerializationTestHelper.GeneratePopulatedDynamicTypesModel();
            var serializer = new JsonSerializer(_mappingRegistry);

            var output = serializer.Serialize(model);

            testOutputHelper.WriteLine("FileSize: " + output.AsString.Length + " bytes");
            testOutputHelper.WriteLine(output.AsString);

            var deserializer     = new JsonDeserializer(_mappingRegistry, _typeCreator);
            var existingInstance = new DynamicTypesModel();

            deserializer.DeserializeInto(output, existingInstance);

            SerializationTestHelper.AssertPopulatedDynamicTypesData(model, existingInstance);
        }