Exemple #1
0
        public static void Setup()
        {
#if !ASYNC
            var pathToTestDirectory = TestContext.CurrentContext.TestDirectory;
            var exportXmlFilePath   = Path.Combine(pathToTestDirectory, "Data", "export.xml");
            _dbFilePath      = Path.Combine(pathToTestDirectory, "Data", "iTunesDB");
            _dbEmptyFilePath = Path.Combine(pathToTestDirectory, "Data", "iTunesDB_Empty");

            Reader      = new MhbdReader();
            ReaderEmpty = new MhbdReader();

            Db      = Reader.Open(_dbFilePath);
            DbEmpty = ReaderEmpty.Open(_dbEmptyFilePath);

            ExportXml = File.ReadAllText(exportXmlFilePath).Replace(Environment.NewLine, "");
#endif
        }
Exemple #2
0
        public string GetXml(iTunesDb db)
        {
            var stringBuilder = new StringBuilder();

            using (var xmlWriter = XmlWriter.Create(stringBuilder))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("mhbd");
                xmlWriter.WriteAttributeString("dbversion", db.Version.ToString());

                WriteListContainerToXml(db.ListContainers, xmlWriter);

                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();
                xmlWriter.Close();
            }

            return(stringBuilder.ToString());
        }