mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-02 00:30:59 +00:00
additional matrix terminal tests and error message correction
This commit is contained in:
parent
72b7c35b3f
commit
eea01c8072
|
|
@ -20,7 +20,7 @@ class MatrixTerminalDefinition(object_id : Int) extends TerminalDefinition(objec
|
|||
"matrix_terminalc"
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("terminal must be either object id 613 or object id 614")
|
||||
throw new IllegalArgumentException("terminal must be object id 517-519")
|
||||
}
|
||||
|
||||
override def Buy(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = Terminal.NoDeal()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.serverobject.terminals.{MatrixTerminalDefinition, Terminal}
|
||||
import net.psforever.objects.{GlobalDefinitions, Player, Vehicle}
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types._
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class MatrixTerminalTest extends Specification {
|
||||
"MatrixTerminal" should {
|
||||
"define (a)" in {
|
||||
val a = new MatrixTerminalDefinition(517)
|
||||
a.ObjectId mustEqual 517
|
||||
a.Name mustEqual "matrix_terminala"
|
||||
}
|
||||
|
||||
"define (b)" in {
|
||||
val b = new MatrixTerminalDefinition(518)
|
||||
b.ObjectId mustEqual 518
|
||||
b.Name mustEqual "matrix_terminalb"
|
||||
}
|
||||
|
||||
"define (b)" in {
|
||||
val b = new MatrixTerminalDefinition(519)
|
||||
b.ObjectId mustEqual 519
|
||||
b.Name mustEqual "matrix_terminalc"
|
||||
}
|
||||
|
||||
"define (invalid)" in {
|
||||
var id : Int = (math.random * Int.MaxValue).toInt
|
||||
if(id == 517) {
|
||||
id += 3
|
||||
}
|
||||
else if(id == 518) {
|
||||
id += 2
|
||||
}
|
||||
else if(id == 519) {
|
||||
id += 1
|
||||
}
|
||||
|
||||
new MatrixTerminalDefinition(id) must throwA[IllegalArgumentException]
|
||||
}
|
||||
}
|
||||
|
||||
"Matrix_Terminal" should {
|
||||
val terminal = Terminal(GlobalDefinitions.matrix_terminalc)
|
||||
terminal.Owner = Vehicle(GlobalDefinitions.quadstealth)
|
||||
terminal.Owner.Faction = PlanetSideEmpire.TR
|
||||
|
||||
"construct" in {
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can not buy (anything)" in {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 1, "lite_armor", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue