public void CheckWriteBookEntity() { var expectedBook = "<?xml version=\"1.0\" encoding=\"utf-16\"?><library>" + GetBookXml() + "</library>"; StringBuilder actualBook = new StringBuilder(); StringWriter stringWriter = new StringWriter(actualBook); librarySystem.WriteTo(new List <IEntity> { GetBookEntity() }, stringWriter); Assert.AreEqual(expectedBook.Trim(), actualBook.ToString().Trim()); stringWriter.Dispose(); }
/// <summary> /// TODO: /// - Move pathes to config file /// - XmlValidationException handling (try/catch) /// </summary> static void Main(string[] args) { var pathToXmlToReadFrom = @"D:\1.xml"; var pathToXmlToWriteIn = @"D:\2.xml"; List <IEntity> entities = new List <IEntity>(); ReadWriteLibrarySystem librarySystem = new ReadWriteLibrarySystem(); using (StreamReader sr = new StreamReader(pathToXmlToReadFrom)) { entities = librarySystem.ReadFrom(sr).ToList(); } using (StreamWriter sr = new StreamWriter(pathToXmlToWriteIn)) { librarySystem.WriteTo(entities, sr, true); } }