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"); }
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); }
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); } }
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"); }