require 'test/unit'
require 'music_metadata_score'

class AritstTest < Test::Unit::TestCase

	# are_proper_artist_format?
	def test_are_proper_artist_format_should_return_false_if_blank_array
		refute Artist.are_proper_artist_format?([], false, :product)
	end
	
	def test_are_proper_artist_format_should_return_false_nil
		refute Artist.are_proper_artist_format?(nil, false, :product)
	end
	
	# loop_artists
	def test_loop_artists_should_return_false_if_passed_a_badly_formatted_artists
		refute Artist.loop_artists(['the rolling stones', 'Tom Allen'], false, :product)
	end
	
	def test_loop_artists_should_return_true_if_passed_proper_formatted_artists
		assert Artist.loop_artists(['The Rolling Stones', 'Tom Allen'], false, :product)
	end
	
	# is_proper_artist_format?
	def test_is_proper_artist_format_should_return_true_if_normal_artist
		assert Artist.is_proper_artist_format?('Tom Allen', false, :product)
	end
	
	def test_is_proper_artist_format_should_return_false_if_bad_title_casing
		refute Artist.is_proper_artist_format?('TOM ALLEN', false, :product)
	end
	
	def test_is_proper_artist_format_should_return_false_if_various_artists_at_track_level
		refute Artist.is_proper_artist_format?('Various Artists', false, :track)
	end
	
	def test_is_proper_artist_format_should_return_false_if_compound_artist
		refute Artist.is_proper_artist_format?('Tom Allen & Another', false, :product)
	end
	
	# is_title_case?
	def test_is_title_case_should_return_true_if_title_case
		assert Artist.is_title_case?('Tom Allen', false)
	end
	
	def test_is_title_case_should_return_false_if_artist_is_not_title_case
		refute Artist.is_title_case?('TOM ALLEN', false)
	end
	
	def test_is_title_case_should_return_true_if_override_is_true
		assert Artist.is_title_case?('TOM ALLEN', true)
	end
	
	# is_compound_artist?
	def test_is_compound_artist_should_return_false_if_string_does_not_contain_and
		refute Artist.is_compound_artist?('Tom Allen', false)
	end
	
	def test_is_compound_artist_should_return_true_if_string_contains_and
		assert Artist.is_compound_artist?('Tom and Allen', false)
		assert Artist.is_compound_artist?('Tom & Allen', false)
	end
	
	def test_is_compound_artist_should_return_true_if_string_contains_with_vs_feat
		assert Artist.is_compound_artist?('Tom Allen feat. another', false)
		assert Artist.is_compound_artist?('Tom Allen VS. another', false)
		assert Artist.is_compound_artist?('Tom Allen with another', false)
	end
	
	def test_is_compound_artist_should_return_false_if_override_is_true
		refute Artist.is_compound_artist?('Tom & Allen', true)
	end
	
	# is_bad_various_artists?
	def test_is_bad_various_artists_should_return_false_if_Various_Artists
		refute Artist.is_bad_various_artists?('Various Artists')
	end
	
	def test_is_bad_various_artists_should_return_false_if_any_other_artist_name
		refute Artist.is_bad_various_artists?('Tom Allen')
	end
	
	def test_is_bad_various_artists_should_return_true_if_contains_any_bad_various_artist_versions
		assert Artist.is_bad_various_artists?('Various')
		assert Artist.is_bad_various_artists?('V/A')
	end
	
	# artist_fits_level?
	def test_artist_fits_level_should_return_false_if_various_artists_and_true_track_level
		refute Artist.artist_fits_level?('Various Artists', false, :track)
		refute Artist.artist_fits_level?('V/A', false, :track)
	end
	
	def test_artist_fits_level_should_return_true_if_various_artists_at_product_level
		assert Artist.artist_fits_level?('Various Artists', false, :product)
	end
	
	def test_artist_fits_level_should_return_true_if_override_is_true
		assert Artist.artist_fits_level?('Various Artists', true, :track)
	end
	
	# format_artists
	def test_format_artists_should_return_an_array
		assert_instance_of Array, Artist.format_artists(['One', 'Two'], false, :product)
	end
	
	def test_format_artists_should_title_case_all_artists
		assert_equal ['One', 'Two'], Artist.format_artists(['ONE', 'two'], false, :product)
	end
	
	def test_format_artists_should_separate_any_compound_artists
		assert_equal ['One', 'Two', 'Three'], Artist.format_artists(['ONE', 'two & THREE'], false, :product)
	end
	
	# title_case
	def test_title_case_should_return_a_string
		assert_instance_of String, Artist.title_case('Tom Allen')
	end
	
	def test_title_case_should_title_case_a_string
		assert_equal "Hello The World", Artist.title_case('HELLO THE WORLD')
	end
	
	# capitalize_the
	def test_capitalize_the_should_return_string
		assert_instance_of String, Artist.capitalize_the('Hello the World')
	end
	
	def test_capitalize_the_should_capitalize_all_thes_in_the_middle_of_a_string
		assert_equal "Hello The World", Artist.capitalize_the('Hello the World')
	end
	
	# separate_compound_artists
	def test_separate_compound_artists_should_return_an_array
		assert_instance_of Array, Artist.separate_compound_artists('hello')
	end
	
	def test_separate_compound_artists_should_separate_any_artists_that_contain_any_connecting_words
		assert_equal ["Tom Allen", "Rusty Bradshaw"], Artist.separate_compound_artists('Tom Allen & Rusty Bradshaw')
	end
	
	# split_artists
	def test_split_artists_should_return_an_array
		assert_instance_of Array, Artist.split_artists('Tom & John', '&')
	end
	
	def test_split_artists_should_split_artists_at_separator
		assert_equal 2, Artist.split_artists('Tom & John', '&').count
	end
	
	def test_split_artists_should_strip_the_artist_names
		assert_equal 'Tom', Artist.split_artists('Tom & John', '&')[0]
	end

end