-added raceStatusDecpderTest -fix a problem where the encoder method for race status added 4 bytes where it should have put 1 -added getters to the info in raceStatusDecoder -fixed a problem with the values looked for in the decoder #story[782]main
parent
fdd994b7c0
commit
49fc4ec02e
@ -0,0 +1,49 @@
|
||||
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.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((short)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());
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue