+TEST "Registering a player returns an ID"
+carl_id=$(empires_register Carl "Bugs Bunny" | jq -r .)
+test "$carl_id" = "1"
+TEST_END
+
+TEST "Registering several more players"
+empires_register Richard "Bob Hope" > /dev/null
+empires_register Kevin "Elvis Presley" > /dev/null
+empires_register Stacy Phineas > /dev/null
+empires_register David "Red Power Ranger" > /dev/null
+empires_register Nancy "Audrey Hepburn" > /dev/null
+bogus_id=$(empires_register Bogus "Mr. Bogus")
+TEST_END
+
+TEST 'Verify complete players list (with "Bogus")'
+players=$(empires_players_string)
+test "$players" = "Carl,Richard,Kevin,Stacy,David,Nancy,Bogus,"
+TEST_END
+
+TEST 'Verify complete players list (with "Mr. Bogus")'
+characters=$(empires_characters_string)
+test "$characters" = "Bugs Bunny,Bob Hope,Elvis Presley,Phineas,Red Power Ranger,Audrey Hepburn,Mr. Bogus,"
+TEST_END
+
+TEST_SUBSECTION "Empires game /deregister"
+
+empires_deregister()
+{
+ curl_post $empires_game_path/deregister/$1
+}
+
+TEST "Removing the bogus player"
+empires_deregister $bogus_id
+TEST_END
+
+TEST 'Verify modified players list (w/o "Bogus")"'
+players=$(empires_players_string)
+test "$players" = "Carl,Richard,Kevin,Stacy,David,Nancy,"
+TEST_END
+
+TEST 'Verify modified characters list (w/o "Mr. Bogus")'
+characters=$(empires_characters_string)
+test "$characters" = "Bugs Bunny,Bob Hope,Elvis Presley,Phineas,Red Power Ranger,Audrey Hepburn,"
+TEST_END
+
+TEST_SUBSECTION "Empires game /capture"
+
+empires_capture()
+{
+ curl_post $empires_game_path/capture/$1/$2
+}
+
+empires_empires_string()
+{
+ # Get empires as a compact string (much more compact than JSON)
+ curl_get $empires_game_path/empires | jq -c '.[] | [.id,.captures]' | tr '\n' ','
+}
+
+TEST "Verify empires before any captures"
+empires=$(empires_empires_string)
+test "$empires" = "[1,[]],[2,[]],[3,[]],[4,[]],[5,[]],[6,[]],"
+TEST_END
+
+TEST "Perform some captures"
+empires_capture 1 2
+empires_capture 3 5
+empires_capture 4 6
+empires_capture 3 4
+TEST_END
+
+TEST "Verify empires after captures"
+empires=$(empires_empires_string)
+test "$empires" = "[1,[2]],[2,[]],[3,[5,4]],[4,[6]],[5,[]],[6,[]],"
+TEST_END
+
+TEST_SUBSECTION "Empires game /liberate"
+
+empires_liberate()
+{
+ curl_post $empires_game_path/liberate/$1
+}
+
+TEST "Liberate a player"
+empires_liberate 2
+TEST_END
+
+TEST "Verify empires after liberate"
+empires=$(empires_empires_string)
+test "$empires" = "[1,[]],[2,[]],[3,[5,4]],[4,[6]],[5,[]],[6,[]],"
+TEST_END
+
+TEST_SUBSECTION "Empires game /reset"
+
+empires_reset()
+{
+ curl_post $empires_game_path/reset
+}
+
+TEST "Reset the game"
+empires_reset
+TEST_END
+
+TEST "Verify players is now empty"
+players=$(empires_players_string)
+test "$players" = ""
+TEST_END
+
+TEST_SECTION "Tic Tac Toe game"
+
+tictactoe_game_path=tictactoe/$tictactoe_game_id
+
+tictactoe_move()
+{
+ curl_post $tictactoe_game_path/move "{ \"move\": $1 }"
+}
+
+lmno_profile()
+{
+ curl_put /profile "{ \"nickname\": \"$1\" }" "-c .test-cookie"
+}
+
+tictactoe_player_info()
+{
+ curl_get $tictactoe_game_path/events "-m 0.1 -b .test-cookie" 2>&1 \
+ | grep player-info -A 1 \
+ | grep ^data
+}