package utils;

import static org.junit.Assert.assertEquals;

import java.io.File;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import constants.TestConstants;

public class TestAudioUtils {

	private final AudioUtils audioUtils = new AudioUtils();
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void should_return_correct_length() {
	
		double duration = audioUtils.getMp3DurationInSeconds(TestConstants.testAudioFile);
		
		assertEquals(89, duration, 1);
	}
	
	@Test
	public void should_return_negative_value_for_invalid_input() {
		
		assertEquals(-1, audioUtils.getMp3DurationInSeconds(null), 0);
		
		assertEquals(-1, audioUtils.getMp3DurationInSeconds(new File("inexistent")), 0);
	}
}
