Exemplo n.º 1
0
func TestActionsDone(t *testing.T) {
	tick := message.Tick(42)

	action1 := message.NewAction()
	action1.Id = 25
	action1.Initiator = 65

	actions := []*message.Action{action1}
	// TODO: more actions tests, with action params

	testMessage(t, message.Types["actions_done"], func(w io.Writer) error {
		return builder.SendActionsDone(w, tick, actions)
	}, func(conn *message.Conn, t *testing.T) {
		rt, ractions := handler.ReadActionsDone(conn)
		if rt != tick {
			t.Fatal("Sent tick", tick, "but received", rt)
		}

		if len(actions) != len(ractions) {
			t.Fatal("Sent", len(actions), "actions but received", len(ractions))
		}
		for i, action := range actions {
			raction := ractions[i]
			if !action.Equals(raction) {
				t.Fatal("Sent action", action, "but received", raction)
			}
		}
	})
}
Exemplo n.º 2
0
func ReadActionDone(r io.Reader) (action *message.Action) {
	action = message.NewAction()

	Read(r, &action.Initiator, &action.Id)
	// TODO: action params

	return
}