Ejemplo n.º 1
0
        public void FindCatalogedTracksByAlbum()
        {
            // FlatCatalog

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

            PersistentIDCollection trackIDs = catalog.FindTracksByAlbum("Ganging Up on the Sun", "Guster");
            Console.WriteLine(String.Format("FindTracksByAlbum -> {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.FindTracksByAlbum("Ganging Up on the Sun", "Guster");
            Console.WriteLine(String.Format("FindTracksByAlbum -> {0} ms", watch.GetSplitMilliseconds()));

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

            ReportPrivateDelta();

            // Controller

            List<Track> tracks = new List<Track>();
            foreach (PersistentID persistentID in trackIDs)
            {
                Track track = controller.LibraryPlaylist.GetTrack(persistentID);
                tracks.Add(track);
            }

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

            // iTunes

            List<Track> tracks2 = new List<Track>();
            foreach (PersistentID persistentID in trackIDs)
            {
                IITTrack itrack = itunes.LibraryPlaylist.Tracks.get_ItemByPersistentID(
                    persistentID.HighBits, persistentID.LowBits);

                Track track = new Track(itrack);
                tracks2.Add(track);
            }

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

            Assert.AreNotEqual(0, tracks.Count);
        }
Ejemplo n.º 2
0
        public void LoadTerse()
        {
            ICatalog catalog = new TerseCatalog();

            catalog.Initialize(libraryXMLPath);

            string music = catalog.MusicPath;

            //catalog.DeleteFile(@"C:\Music\4 Non Blondes\Bigger, Better, Faster, More\02 Superfly.mp3");
            //catalog.DeleteFile(@"C:\Music\4 Non Blondes\Bigger, Better, Faster, More\02 Superfly.mp3");
        }
Ejemplo n.º 3
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");
        }
Ejemplo n.º 4
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

            using (var controller = new Controller())
            {
                System.Threading.Thread.Sleep(2000);                 // let the controller initialize

                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();
        }
Ejemplo n.º 5
0
        public void FindCatalogedTracksByAlbum()
        {
            // FlatCatalog

            ICatalog catalog = new FlatCatalog();

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

            PersistentIDCollection trackIDs = catalog.FindTracksByAlbum("Ganging Up on the Sun", "Guster");

            Console.WriteLine(String.Format("FindTracksByAlbum -> {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.FindTracksByAlbum("Ganging Up on the Sun", "Guster");
            Console.WriteLine(String.Format("FindTracksByAlbum -> {0} ms", watch.GetSplitMilliseconds()));

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

            ReportPrivateDelta();

            // Controller

            using (var controller = new Controller())
            {
                System.Threading.Thread.Sleep(2000);                 // let the controller initialize

                List <Track> tracks = new List <Track>();
                foreach (PersistentID persistentID in trackIDs)
                {
                    Track track = controller.LibraryPlaylist.GetTrack(persistentID);
                    tracks.Add(track);
                }

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

                // iTunes

                List <Track> tracks2 = new List <Track>();
                foreach (PersistentID persistentID in trackIDs)
                {
                    IITTrack itrack = itunes.LibraryPlaylist.Tracks.get_ItemByPersistentID(
                        persistentID.HighBits, persistentID.LowBits);

                    Track track = new Track(itrack);
                    tracks2.Add(track);
                }

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

                Assert.AreNotEqual(0, tracks.Count);
            }
        }
Ejemplo n.º 6
0
        public void LoadTerse()
        {
            ICatalog catalog = new TerseCatalog();
            catalog.Initialize(libraryXMLPath);

            string music = catalog.MusicPath;

            //catalog.DeleteFile(@"C:\Music\4 Non Blondes\Bigger, Better, Faster, More\02 Superfly.mp3");
            //catalog.DeleteFile(@"C:\Music\4 Non Blondes\Bigger, Better, Faster, More\02 Superfly.mp3");
        }
Ejemplo n.º 7
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");
        }
Ejemplo n.º 8
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();
        }