package seng302.Mock;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

/**
 * Created by jjg64 on 19/04/17.
 * Tests RegattaXMLReader
 */
public class RegattaXMLTest {
    private RegattaXMLReader regatta;

    @Before
    public void findFile() {
        try {
            regatta = new RegattaXMLReader("mockXML/regattaXML/regattaTest.xml");
        } catch (Exception e) {
            fail("Cannot find mockXML/regattaXML/regattaTest.xml in the resources folder");
        }
    }

    @Test
    public void correctValuesTest() {
        assertEquals(regatta.getRegattaID(), 3);
        assertEquals(regatta.getRegattaName(), "New Zealand Test");
        assertEquals(regatta.getCourseName(), "North Head");
        assertEquals(regatta.getCentralLatitude(), -36.82791529, 0.00000001);
        assertEquals(regatta.getCentralLongitude(), 174.81218919, 0.00000001);
        assertEquals(regatta.getCentralAltitude(), 0.00, 0.00000001);
        assertEquals(regatta.getUtcOffset(), 12.0, 0.001);
        assertEquals(regatta.getMagneticVariation(), 14.1, 0.001);
    }
}
