Exemple #1
0
        public void TEST_IMPORT_INTO_DATABASE()
        {
            Console.WriteLine("Running dvd profiler importer");
            DVDProfilerImporter importer = new DVDProfilerImporter();

            importer.DoWork(new[] { @"..\..\..\Sample Files\DVDProfiler - Large.xml" });
            IList <OMLSDKTitle> titles = importer.GetTitles();

            Console.WriteLine("Adding items to the db");
            DateTime start = DateTime.Now;

            foreach (OMLSDKTitle title in titles)
            {
                // save the title - this also generates it an id
                TitleCollectionManager.AddTitle(OMLSDK.SDKUtilities.ConvertOMLSDKTitleToTitle(title));
            }

            // save all the image updates
            TitleCollectionManager.SaveTitleUpdates();

            Console.WriteLine(string.Format("Done - Took: {0} milliseconds for {1} titles",
                                            (DateTime.Now - start).TotalMilliseconds.ToString(),
                                            titles.Count));
        }
Exemple #2
0
        private static OMLSDKTitle LoadTitle(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }

            OMLSDKTitle result = null;

            if (defaultTitles == null)
            {
                DVDProfilerImporter importer;
                using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(defaultSettings), false))
                {
                    importer = new DVDProfilerImporter(new XmlTextReader(ms));
                }

                string xmlPath = @"..\..\..\Sample Files\DVDProfilerUnitTest.xml";
                importer.DoWork(new[] { xmlPath });
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlPath);
                defaultTitles = importer.GetTitles();
                Assert.AreEqual(xmlDoc.SelectNodes("Collection/DVD").Count, defaultTitles.Count, "Unexpected number of profiles loaded.");
            }

            foreach (OMLSDKTitle title in defaultTitles)
            {
                if (title.MetadataSourceID == id)
                {
                    result = title;
                    break;
                }
            }
            Assert.IsNotNull(result, "The DVDProfilerUnitTest.xml file does not contain a title with ID " + id);
            return(result);
        }