mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-28 10:43:37 +00:00
initial work on OxygenStateMessage packet and tests
This commit is contained in:
parent
461a4f9507
commit
729b36eba1
3 changed files with 143 additions and 1 deletions
53
common/src/test/scala/game/OxygenStateMessageTest.scala
Normal file
53
common/src/test/scala/game/OxygenStateMessageTest.scala
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class OxygenStateMessageTest extends Specification {
|
||||
val string_self = hex"78 4b00f430"
|
||||
val string_vehicle = hex"78 4b00f4385037a180"
|
||||
|
||||
"decode (self)" in {
|
||||
PacketCoding.DecodePacket(string_self).require match {
|
||||
case OxygenStateMessage(guid, time, active, veh_state) =>
|
||||
guid mustEqual PlanetSideGUID(75)
|
||||
time mustEqual 50.0
|
||||
active mustEqual true
|
||||
veh_state.isDefined mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (vehicle)" in {
|
||||
PacketCoding.DecodePacket(string_vehicle).require match {
|
||||
case OxygenStateMessage(guid, time, active, veh_state) =>
|
||||
guid mustEqual PlanetSideGUID(75)
|
||||
time mustEqual 50.0
|
||||
active mustEqual true
|
||||
veh_state.isDefined mustEqual true
|
||||
veh_state.get.vehicle_guid mustEqual PlanetSideGUID(1546)
|
||||
veh_state.get.time mustEqual 50.0
|
||||
veh_state.get.active mustEqual true
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (self)" in {
|
||||
val msg = OxygenStateMessage(PlanetSideGUID(75), 50.0, true)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_self
|
||||
}
|
||||
|
||||
"encode (vehicle)" in {
|
||||
val msg = OxygenStateMessage(PlanetSideGUID(75), 50.0, true, WaterloggedVehicleState(PlanetSideGUID(1546), 50.0, true))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_vehicle
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue