public void SerializeDocumentToJson() { var document = new Document { Title = "Heading", Text = "Text Content" }; var serializer = new JsonDestinationSerializer <Document>(); var json = serializer.Serialize(document); Assert.Equal(_jsonExample, json); }
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); }