package seng302.Model;


import org.junit.Test;


import static junit.framework.TestCase.*;

/**
 * Created by esa46 on 22/03/17.
 */
public class BoatTest {


    private GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
    private Boat TEST_BOAT = new Boat("Test", 1, "tt", 1, new Polars());

    @Test
    public void calculateDueNorthAzimuthReturns0() {

        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(50, 0));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
    }

    @Test
    public void calculateDueSouthAzimuthReturns180() {
        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
    }


    @Test
    public void calculateDueEastAzimuthReturns90() {

        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(0, 50));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
    }


    @Test
    public void calculateDueWestAzimuthReturnsNegative90() {
        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(0, -50));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);

    }

    @Test
    public void calculateDueNorthHeadingReturns0() {

        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(50, 0));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
    }


    @Test
    public void calculateDueEastHeadingReturns90() {
        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(0, 50));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
    }

    @Test
    public void calculateDueSouthHeadingReturns180() {
        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
    }

    @Test
    public void calculateDueWestHeadingReturns270() {
        Marker startMarker = new Marker(ORIGIN_COORDS);
        Marker endMarker = new Marker(new GPSCoordinate(0, -50));
        Leg start = new Leg("Start", startMarker, endMarker, 0);
        TEST_BOAT.setCurrentLeg(start);
        assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
    }
}
