Exemplo n.º 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");
        }
Exemplo n.º 2
0
        public void FindCatalogedTracksByArtist()
        {
            // FlatCatalog

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

            PersistentIDCollection trackIDs = catalog.FindTracksByArtist("Guster");
            Console.WriteLine(String.Format("FindTracksByArtist/Flat -> {0} ms", watch.GetSplitMilliseconds()));

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

            // TerseCatalog

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

            trackIDs = catalog.FindTracksByArtist("Guster");
            Console.WriteLine(String.Format("FindTracksByArtist/Terse -> {0} ms", watch.GetSplitMilliseconds()));

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

            // Controller

            trackIDs = new PersistentIDCollection();
            foreach (Track track in controller.LibraryPlaylist.Tracks.Values)
            {
                if ((track != null) && !String.IsNullOrEmpty(track.Artist))
                {
                    if (track.Artist.Equals("Guster"))
                    {
                        trackIDs.Add(track.PersistentID);
                    }
                }
            }

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

            // iTunes

            trackIDs = new PersistentIDCollection();
            foreach (IITTrack track in itunes.LibraryPlaylist.Tracks)
            {
                if ((track != null) && !String.IsNullOrEmpty(track.Artist))
                {
                    if (track.Artist.Equals("Guster"))
                    {
                        trackIDs.Add(GetPersistentID(track));
                    }
                }
            }

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

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