Ejemplo n.º 1
0
func TestPowerup(t *testing.T) {
	Convey("powerup Command", t, func() {
		fire := cmd.NewPowerup()
		So(fire.UniqueId, ShouldEqual, "")
		So(fire.Subtype, ShouldEqual, cmd.POWERUP)
		So(fire.Type, ShouldEqual, cmd.Post)
		So(fire.Type, ShouldEqual, fire.Command().Type)
		So(fire.Subtype, ShouldEqual, fire.Command().Subtype)
		So(fire.UniqueId, ShouldEqual, fire.Command().UniqueId)
	})
}
func TestDecodePowerup(t *testing.T) {
	Convey("Fire powerup", t, func() {
		formatter := encoder.JsonEncoderDecoder{Tag: "DecodeTest"}

		data := cmd.NewPowerup()
		data.UniqueId = "ABC123"
		buffer, error := json.Marshal(data)

		command, err := formatter.Decode(buffer)

		turn := command.(*cmd.PowerupCommand)

		So(error, ShouldEqual, nil)
		So(turn.Command().Type, ShouldEqual, cmd.Post)
		So(turn.Command().Subtype, ShouldEqual, cmd.POWERUP)
		So(err, ShouldEqual, nil)
		So(turn.Command().UniqueId, ShouldEqual, "ABC123")
	})
}