Example #1
0
        public void FlatTerseComparisons()
        {
            // create two playlists, both name "Ben" and use this to test that we can
            // find the extensions in the first one

            ICatalog flat = new FlatCatalog();
            flat.Initialize(libraryXMLPath);

            ICatalog terse = new TerseCatalog();
            terse.Initialize(libraryXMLPath);

            PersistentID pid = GetPlaylistPersistentID("Ben");

            // FindExtensionsByPlaylist()

            StringCollection flatExtensions = flat.FindExtensionsByPlaylist(pid);
            Assert.IsNotNull(flatExtensions);
            Assert.AreNotEqual(0, flatExtensions.Count);

            StringCollection terseExtensions = terse.FindExtensionsByPlaylist(pid);
            Assert.IsNotNull(terseExtensions);
            Assert.AreNotEqual(0, terseExtensions.Count);

            Assert.AreEqual(flatExtensions.Count, terseExtensions.Count);

            foreach (string ext in terseExtensions)
            {
                Assert.IsTrue(flatExtensions.Contains(ext));
            }

            Console.WriteLine("FindExtensionsByPlaylist() OK");

            // FindPlaylistName()

            string name = flat.FindPlaylistName(pid);
            Assert.AreEqual("Ben", name);

            name = terse.FindPlaylistName(pid);
            Assert.AreEqual("Ben", name);

            Console.WriteLine("FindPlaylistName() OK");

            // FindTracksByAlbum()

            PersistentIDCollection flatTracks =
                flat.FindTracksByAlbum("Greatest Hits", "Alice Cooper");
            Assert.IsNotNull(flatTracks);
            Assert.AreNotEqual(0, flatTracks.Count);

            PersistentIDCollection terseTracks =
                terse.FindTracksByAlbum("Greatest Hits", "Alice Cooper");
            Assert.IsNotNull(terseTracks);
            Assert.AreNotEqual(0, terseTracks.Count);

            Assert.AreEqual(flatTracks.Count, terseTracks.Count);

            foreach (PersistentID id in terseTracks)
            {
                Assert.IsTrue(flatTracks.Contains(id));
            }

            Console.WriteLine("FindTracksByAlbum() OK");

            // FindTracksByArtist()

            flatTracks = flat.FindTracksByArtist("Alice Cooper");
            Assert.IsNotNull(flatTracks);
            Assert.AreNotEqual(0, flatTracks.Count);

            terseTracks = terse.FindTracksByArtist("Alice Cooper");
            Assert.IsNotNull(terseTracks);
            Assert.AreNotEqual(0, terseTracks.Count);

            Assert.AreEqual(flatTracks.Count, terseTracks.Count);

            foreach (PersistentID id in terseTracks)
            {
                Assert.IsTrue(flatTracks.Contains(id));
            }

            Console.WriteLine("FindTracksByArtist() OK");

            // FindTracksByPlaylist()

            pid = GetPlaylistPersistentID("My Top Rated");

            flatTracks = flat.FindTracksByPlaylist(pid);
            Assert.IsNotNull(flatTracks);
            Assert.AreNotEqual(0, flatTracks.Count);

            terseTracks = terse.FindTracksByPlaylist(pid);
            Assert.IsNotNull(terseTracks);
            Assert.AreNotEqual(0, terseTracks.Count);

            Assert.AreEqual(flatTracks.Count, terseTracks.Count);

            foreach (PersistentID id in terseTracks)
            {
                Assert.IsTrue(flatTracks.Contains(id));
            }

            Console.WriteLine("FindTracksByPlaylist() OK");
        }
Example #2
0
        public void FindCatalogedTracksByPlaylist()
        {
            // FlatCatalog

            ICatalog catalog = new FlatCatalog();
            catalog.Initialize(libraryXMLPath);
            Console.WriteLine(String.Format("new FlatCatalog() -> {0} ms", watch.GetSplitMilliseconds()));

            List<IITTrack> tracks = new List<IITTrack>();

            PersistentID pid = GetPlaylistPersistentID("ituner");
            PersistentIDCollection persistentIDs = catalog.FindTracksByPlaylist(pid);

            foreach (PersistentID persistentID in persistentIDs)
            {
                IITTrack itrack = itunes.LibraryPlaylist.Tracks.get_ItemByPersistentID(
                    persistentID.HighBits, persistentID.LowBits);

                tracks.Add(itrack);
            }

            Console.WriteLine(String.Format("FindTracksByPlaylist -> {0} ms", watch.GetSplitMilliseconds()));

            Assert.IsNotNull(persistentIDs);
            Assert.AreNotEqual(0, persistentIDs.Count);
            Console.WriteLine(String.Format("Found {0} tracks", persistentIDs.Count));

            watch.Stop();
            Console.WriteLine(String.Format("Completed in {0} ms", watch.GetElapsedMilliseconds()));

            // iTunes

            watch.Reset();
            watch.Start();

            IITTrackCollection itracks =
                itunes.LibrarySource.Playlists.get_ItemByName("ituner").Tracks;

            Console.WriteLine(String.Format("get_ItemByName -> {0} ms", watch.GetSplitMilliseconds()));

            watch.Stop();
            Console.WriteLine(String.Format("Completed in {0} ms", watch.GetElapsedMilliseconds()));
        }