using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using MusicMetaTagger.Client.AllMusicGuide.RemoteDataAccess;
using MusicMetaTagger.Client.AllMusicGuide.RemoteDataAccess.Scraper;
using MusicMetaTagger.Client.AllMusicGuide.Services;
using MusicMetaTagger.Core.Queries;
using NUnit.Framework;

namespace MusicMetaTagger.Client.AllMusicGuide.Tests.Services
{
	[TestFixture]
	public class MusicGuideSearcherTests
	{
		[Test, Explicit]
		public void SearchTrackTests()
		{
			var trackSearcher = new TrackSearcher(
				new MusicGuideScraper(
					new AlbumScraper(), new AlbumResultPageScraper(), 
					new ArtistScraper(), new ArtistResultPageScraper(), new ArtistDiscographyScraper(),
					new SongResultPageScraper(), new SongScraper()));

			trackSearcher.SearchStatusUpdate += status => Debug.WriteLine(status.Status);

			var trackQueries =
				new List<TrackQuery>
					{
						//new TrackQuery { ArtistName = "The Beach Boys", AlbumTitle = "The Smile Sessions", TrackTitle = "Gee", TrackLength = new TimeSpan(0,0,0,52), TrackNumber = 2},
						//new TrackQuery { ArtistName = "Wipers", AlbumTitle = "Wipers Box Set (disc 2: Youth of America)", TrackTitle = "When It's Over", TrackLength = new TimeSpan(0,0,6,36), TrackNumber = 6},
						//new TrackQuery { ArtistName = "Bonnie 'Prince' Billy & Matt Sweeney", AlbumTitle = "Superwolf", TrackTitle = "My Home Is the Sea", TrackLength = new TimeSpan(0,0,5,49), TrackNumber = 1},
						//new TrackQuery { ArtistName = "Aimee Mann & Michael Penn", AlbumTitle = "I Am Sam", TrackTitle = "Two of Us", TrackLength = new TimeSpan(0,0,3,31), TrackNumber = 1},
						//new TrackQuery { ArtistName = "rufus wainwright", AlbumTitle = "I Am Sam", TrackTitle = "Across the Universe", TrackLength = new TimeSpan(0,0,4,08), TrackNumber = 3},
						//new TrackQuery { ArtistName = "T.I.", AlbumTitle = "Pitchfork - Best of 2006", TrackTitle = "What You Know", TrackLength = new TimeSpan(0,0,4,34), AlbumPartOfCompilation = true},
						//new TrackQuery { ArtistName = "Dios", AlbumTitle = "Dios", TrackTitle = "Nobody's Perfect", TrackLength = new TimeSpan(0,0,5,27), TrackNumber = 1},
						//new TrackQuery {ArtistName = "Jan Hammer", TrackTitle = "Crockett's Theme"}
						//new TrackQuery { AlbumTitle = "Magnolia", TrackTitle = "One"},
						//new TrackQuery {ArtistName = "!!!", TrackTitle = "Myth Takes"},
						//new TrackQuery {ArtistName = "!!!", AlbumTitle = "Myth Takes", TrackTitle = "Myth Takes", TrackNumber = 1},
						//new TrackQuery {ArtistName = "Queen", TrackTitle = "Another One Bites the Dust"},
						//new TrackQuery {ArtistName = "Radiohad", TrackTitle = "Paranod Androd"},
						//new TrackQuery{ArtistName = "Modest Mouse", AlbumTitle = "The Lonely Crowded West", TrackTitle = "Cowboy Dan"},
						//new TrackQuery("Ruling the World") {ArtistName = "Jarvis Cocker"},
						//new TrackQuery {ArtistName = "Radiohead", TrackTitle = "Melatonin"}
						//new TrackQuery {ArtistName = "Flying Lotus feat. Thom Yorke", TrackTitle = "...and the World Laughs With You", AlbumArtistName = "Flying Lotus"},
						//new TrackQuery {ArtistName = "Flying Lotus", TrackTitle = "...and the World Laughs With You", AlbumArtistName = "Flying Lotus"}
						//new TrackQuery {ArtistName = "Bill Frisell", TrackTitle = "I Heard It Through the Grapevine", AlbumTitle = "East/West"}
						//new TrackQuery {ArtistName = "Christopher O'Riley", TrackTitle = "Everything In It's Right Place", AlbumTitle = "True Love Waits: Christopher O'Riley Plays Radiohead"}
						//new TrackQuery {ArtistName = "Roger Waters", TrackTitle = "Comfortably Numb (live) (feat. Van Morrison & The Band)", AlbumTitle = "The Departed", AlbumPartOfCompilation = true, TrackLength = new TimeSpan(0,0,8,0), TrackNumber = 1}
						//new TrackQuery {ArtistName = "Sharon Phillips", TrackTitle = "Want 2 / Need 2 (Trentemøller remix)", AlbumTitle = "The Trentemøller Chronicles (disc 2)", AlbumPartOfCompilation = false, TrackLength = new TimeSpan(0,0,6,03), TrackNumber = 8},
						//new TrackQuery {ArtistName = "Cozy Powell", TrackTitle = "Dance with the Devil", AlbumTitle = "Hot Fuzz", AlbumPartOfCompilation = false, TrackLength = new TimeSpan(0,0,3,17), TrackNumber = 5}
						new TrackQuery {ArtistName = "Alice in Chains", TrackTitle = "Rooster", AlbumTitle = "Dirt", AlbumPartOfCompilation = false, TrackLength = new TimeSpan(0,0,6,15), TrackNumber = 5}
					};
			

			foreach (var track in trackQueries.Select(trackQuery => trackSearcher.SearchTrack(trackQuery, new CancellationToken())))
			{
				Assert.IsNotNull(track);
			}
		}
	}
}
