You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.8 KiB
50 lines
1.8 KiB
package seng302.Networking.MessageDecoders;
|
|
|
|
import javafx.scene.paint.Color;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
import seng302.Model.BoatInRace;
|
|
import seng302.Model.Leg;
|
|
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
* Created by hba56 on 23/04/17.
|
|
*/
|
|
public class RaceStatusDecoderTest {
|
|
@Test
|
|
public void getByteArrayTest(){
|
|
long time = System.currentTimeMillis();
|
|
BoatInRace boat1 = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
|
Leg testLeg = new Leg("test leg", 1);
|
|
boat1.setCurrentLeg(testLeg);
|
|
BoatInRace boat2 = new BoatInRace("Test2", 1, Color.ALICEBLUE, "tt");
|
|
boat2.setCurrentLeg(testLeg);
|
|
ArrayList boats = new ArrayList();
|
|
boats.add(boat1);
|
|
boats.add(boat2);
|
|
long time2 = System.currentTimeMillis();
|
|
|
|
RaceVisionByteEncoder raceVisionByteEncoder = new RaceVisionByteEncoder();
|
|
|
|
byte[] encodedRaceStatus = raceVisionByteEncoder.raceStatus(time, 1, 2, time2,
|
|
(short)2, (short)3,4, boats);
|
|
|
|
RaceStatusDecoder decoderTest = new RaceStatusDecoder(encodedRaceStatus);
|
|
|
|
Assert.assertEquals(0b10, decoderTest.getVersionNum());
|
|
Assert.assertEquals(time, decoderTest.getTime());
|
|
Assert.assertEquals(1, decoderTest.getRace());
|
|
Assert.assertEquals(2, decoderTest.getRaceState());
|
|
Assert.assertEquals(time2, decoderTest.getStartTime());
|
|
Assert.assertEquals(2, decoderTest.getRaceWindDir());
|
|
Assert.assertEquals((short)3, decoderTest.getRaceWindSpeed());
|
|
|
|
Assert.assertEquals(0, decoderTest.getBoats().get(0).getBoatStatus());
|
|
Assert.assertEquals(0, decoderTest.getBoats().get(0).getLegNumber());
|
|
Assert.assertEquals(0, decoderTest.getBoats().get(0).getNumPenaltiesAwarded());
|
|
|
|
}
|
|
}
|