package seng302.Networking.MessageDecoders;

import org.junit.Assert;
import org.junit.Test;
import seng302.Networking.Messages.BoatLocation;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;


/**
 * Created by hba56 on 23/04/17.
 */
public class BoatLocationDecoderTest {
    @Test
    public void getByteArrayTest(){
        long time = System.currentTimeMillis();
        BoatLocation testMessage = new BoatLocation((byte) 1, time, 2,
                3, (byte)  1, 180, -180, 4, 5,
                (short) 6, (short) 7, 8, 9, 10, 11,
                (short) 12, 13, 14 , (short) 15,
                16, 17, (short) 18);
        RaceVisionByteEncoder raceVisionByteEncoder = new RaceVisionByteEncoder();
        byte [] testEncodedMessage = raceVisionByteEncoder.boatLocation(testMessage);

        BoatLocationDecoder testDecoder = new BoatLocationDecoder(testEncodedMessage);
        BoatLocation decodedTest = testDecoder.getMessage();

        Assert.assertEquals(testMessage.getMessageVersionNumber(), decodedTest.getMessageVersionNumber());
        Assert.assertEquals(testMessage.getTime(), decodedTest.getTime());
        Assert.assertEquals(testMessage.getSequenceNumber(), decodedTest.getSequenceNumber());
        Assert.assertEquals(testMessage.getDeviceType(), decodedTest.getDeviceType());
        Assert.assertEquals(testMessage.getLatitude(), decodedTest.getLatitude());
        Assert.assertEquals(testMessage.getLongitude(), decodedTest.getLongitude());
        Assert.assertEquals(testMessage.getAltitude(), decodedTest.getAltitude());
        Assert.assertEquals(testMessage.getHeading(), decodedTest.getHeading());
        Assert.assertEquals(testMessage.getPitch(), decodedTest.getPitch());
        Assert.assertEquals(testMessage.getRoll(), decodedTest.getRoll());
        Assert.assertEquals(testMessage.getBoatSpeed(), decodedTest.getBoatSpeed());

        Assert.assertEquals(testMessage.getBoatCOG(), decodedTest.getBoatCOG());
        Assert.assertEquals(testMessage.getBoatSOG(), decodedTest.getBoatSOG());
        Assert.assertEquals(testMessage.getApparentWindSpeed(), decodedTest.getApparentWindSpeed());
        Assert.assertEquals(testMessage.getTrueWindSpeed(), decodedTest.getTrueWindSpeed());
        Assert.assertEquals(testMessage.getTrueWindDirection(), decodedTest.getTrueWindDirection());
        Assert.assertEquals(testMessage.getTrueWindAngle(), decodedTest.getTrueWindAngle());
        Assert.assertEquals(testMessage.getCurrentDrift(), decodedTest.getCurrentDrift());
        Assert.assertEquals(testMessage.getCurrentSet(), decodedTest.getCurrentSet());
        Assert.assertEquals(testMessage.getRudderAngle(), decodedTest.getRudderAngle());
    }
}
