public void Lab5_GreyWarden_Serialize_Doc_2() { var xmlDocSerializer = new XmlDocumentSerializer(); var hdd = fixture.Create <Hdd>(); var xmlDoc = xmlDocSerializer.Serialize(hdd); var resultHdd = xmlDocSerializer.Deserialize <Hdd>(xmlDoc); Assert.AreEqual(hdd.Capacity, resultHdd.Capacity); Assert.AreEqual(hdd.Interface, resultHdd.Interface); Assert.AreEqual(hdd.RecordingSpeed, resultHdd.RecordingSpeed); }
public void Lab5_GreyWarden_Serialize_Doc_3() { var xmlDocSerializer = new XmlDocumentSerializer(); var list = new List <Hdd> { fixture.Create <Hdd>() }; var xmlDoc = xmlDocSerializer.Serialize(list); var resultList = xmlDocSerializer.Deserialize <List <Hdd> >(xmlDoc); Assert.AreEqual(list[0].Capacity, resultList[0].Capacity); Assert.AreEqual(list[0].Interface, resultList[0].Interface); Assert.AreEqual(list[0].RecordingSpeed, resultList[0].RecordingSpeed); }
public void Lab5_GreyWarden_Serialize_Doc_1() { var xmlDocSerializer = new XmlDocumentSerializer(); var hdd = fixture.Create <Hdd>(); var xmlDoc = xmlDocSerializer.Serialize(hdd); var capacity = xmlDoc.GetElementsByTagName("Capacity"); Assert.IsTrue(capacity.Count > 0 && capacity[0].InnerText == hdd.Capacity.ToString()); var hddInterface = xmlDoc.GetElementsByTagName("Interface"); Assert.IsTrue(hddInterface.Count > 0 && hddInterface[0].InnerText == hdd.Interface); var recordingSpeed = xmlDoc.GetElementsByTagName("RecordingSpeed"); Assert.IsTrue(recordingSpeed.Count > 0 && recordingSpeed[0].InnerText == hdd.RecordingSpeed.ToString()); }
static async Task Main(string[] args) { // Initialize dependencies. var jsonSerializer = new JsonDocumentSerializer(); var xmlSerializer = new XmlDocumentSerializer(); var converter = new ConverterBase <Document>(new ISerializer <Document>[] { jsonSerializer, xmlSerializer, }); var webStorage = new WebStorage(); var fileSystemStorage = new FileSystemStorage(); var storageProvider = new StorageProvider.Storage.StorageProvider(new IStorage[] { webStorage, fileSystemStorage, }); var app = new Application(converter, storageProvider); // Run application. var fromUri = new Uri("https://gist.githubusercontent.com/daywee/155b9145f00967cffac2933869614d6c/raw/835a0feef86d671077a210b92e11f318abd0acb5/rwsDocument.json"); string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var toUri = new Uri(Path.Combine(documentsPath, "rwsHomework.xml")); await app.Convert(fromUri, toUri); }