Beispiel #1
0
        public void DeserializeDocumentFromXml()
        {
            var expected = new Document {
                Title = "Heading", Text = "Text Content"
            };
            var deserializer = new XmlSourceDeserializer <Document>(_encoding);

            var document = deserializer.Deserialize(_xmlExample);

            Assert.Equal(document.Title, expected.Title);
            Assert.Equal(document.Text, expected.Text);
        }
Beispiel #2
0
        public async void ConvertXmlFileToJsonFile()
        {
            var source          = new FileSource("./document.xml", _encoding);
            var deserializer    = new XmlSourceDeserializer <Document>(_encoding);
            var serializer      = new JsonDestinationSerializer <Document>();
            var destinationPath = "./Temp/document.json";
            var destination     = new FileDestination(destinationPath, _encoding);
            var conversion      = new FormatConversion <string, Document, string>(source, deserializer, serializer, destination);

            await conversion.RunAsync();

            var output = await File.ReadAllTextAsync(destinationPath, _encoding);

            Assert.Equal(_jsonExample, output);
        }