public void should_serialize_populated_data_with_debug_serializer()
        {
            var model      = SerializationTestHelper.GeneratePopulatedModel();
            var serializer = new DebugSerializer(_mappingRegistry);

            var output = serializer.Serialize(model);

            testOutputHelper.WriteLine(output.AsString);
        }
Beispiel #2
0
        public void check_it_converts_sensibly()
        {
            var serializer    = new BsonSerializer(_mappingRegistry);
            var deserializer  = new BsonDeserializer(_mappingRegistry, _typeCreator);
            var expectedModel = SerializationTestHelper.GeneratePopulatedModel();

            var data = serializer.Serialize(expectedModel);

            _testOutputHelper.WriteLine("Outputted Bson: ");
            _testOutputHelper.WriteLine(BitConverter.ToString(data.AsBytes));

            var actualModel = deserializer.Deserialize <ComplexModel>(data);

            SerializationTestHelper.AssertPopulatedData(expectedModel, actualModel);
        }
        public void should_correctly_serialize_populated_data_with_binary()
        {
            var model = SerializationTestHelper.GeneratePopulatedModel();

            var serializer = new BinarySerializer(_mappingRegistry);
            var output     = serializer.Serialize(model);

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

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

            SerializationTestHelper.AssertPopulatedData(model, result);
        }
        public void should_correctly_serialize_populated_data_into_existing_object_with_json()
        {
            var model      = SerializationTestHelper.GeneratePopulatedModel();
            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 result       = new ComplexModel();

            deserializer.DeserializeInto(output, result);

            SerializationTestHelper.AssertPopulatedData(model, result);
        }
Beispiel #5
0
        public void check_it_converts_sensibly()
        {
            var model         = SerializationTestHelper.GeneratePopulatedModel();
            var expectdString = Transformer.ToJson(model);

            testOutputHelper.WriteLine("Outputted Json: ");
            testOutputHelper.WriteLine(expectdString);
            var xml = Transformer.FromJsonToXml <ComplexModel>(expectdString);

            testOutputHelper.WriteLine("Converted Xml: ");
            testOutputHelper.WriteLine(xml);
            var binary = Transformer.FromXmlToBinary <ComplexModel>(xml);

            testOutputHelper.WriteLine("Converted Binary: ");
            testOutputHelper.WriteLine(BitConverter.ToString(binary));
            var json = Transformer.FromBinaryToJson <ComplexModel>(binary);

            testOutputHelper.WriteLine("Outputted Json: ");
            testOutputHelper.WriteLine(json);
            Assert.AreEqual(expectdString, json);
        }