mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-04-23 04:45:22 +00:00
34 lines
945 B
Scala
34 lines
945 B
Scala
|
|
// Copyright (c) 2017 PSForever
|
||
|
|
package game
|
||
|
|
|
||
|
|
import org.specs2.mutable._
|
||
|
|
import net.psforever.packet._
|
||
|
|
import net.psforever.packet.game._
|
||
|
|
import scodec.bits._
|
||
|
|
|
||
|
|
class FavoritesRequestTest extends Specification {
|
||
|
|
val stringInfantry = hex"5E 4B00 1187 4500 7800 6100 6D00 7000 6C00 6500"
|
||
|
|
|
||
|
|
"decode (for infantry)" in {
|
||
|
|
PacketCoding.DecodePacket(stringInfantry).require match {
|
||
|
|
case FavoritesRequest(player_guid, unk, action, line, label) =>
|
||
|
|
player_guid mustEqual PlanetSideGUID(75)
|
||
|
|
unk mustEqual 0
|
||
|
|
action mustEqual FavoritesAction.Save
|
||
|
|
line mustEqual 1
|
||
|
|
label.isDefined mustEqual true
|
||
|
|
label.get mustEqual "Example"
|
||
|
|
case _ =>
|
||
|
|
ko
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
"encode (for infantry)" in {
|
||
|
|
val msg = FavoritesRequest(PlanetSideGUID(75), 0, FavoritesAction.Save, 1, Some("Example"))
|
||
|
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||
|
|
|
||
|
|
pkt mustEqual stringInfantry
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|