Added ggs_player_test skeleton. Return in player start_link is now {ok, Pid} | {error, Reason}.

This commit is contained in:
Kallfaktorn 2011-02-16 21:18:32 +01:00
parent c63e243564
commit 2455f5582c
2 changed files with 28 additions and 4 deletions

View file

@ -11,7 +11,7 @@
%% @doc Spawns a process representing the player in GGS. Takes the player socket as
%% an argument for storage and later usage. Creates a unique player token
%% identifying the player.
%% @spec start_link(Socket::socket()) -> ok
%% @spec start_link(Socket::socket()) -> {ok, Pid} | {error, Reason}
start_link(Socket) ->
loop(Socket).
@ -27,10 +27,11 @@ notify(Player, From, Message) ->
get_token(_Player) ->
helpers:not_implemented().
%% @doc Properly terminates the player process. The player token will be destroyed.
%% Makes table token unreferenced and destroys the process in the end.
%% @doc Properly terminates the player process. The player token will be lost
%% together with the table token. It should also close the player socket and the
%% process should return in the end.
%% @spec stop(Table::pid()) -> Reason::string()
stop(_Table) ->
stop(_Player,_Table) ->
helpers:not_implemented().
%% Internals

23
tests/ggs_player_test.erl Normal file
View file

@ -0,0 +1,23 @@
-include_lib("eunit/include/eunit.hrl").
-import(ggs_player).
%% @doc start_link should always return ok for any valid socket. A valid socket
%% should always return {ok, Pid} and {error, Reason} otherwise.
start_link_test() ->
helpers:not_implemented().
%% @doc Given that start_link returned {ok, Player}. Notify shall always return ok and
%% deliver a specified message through the socket.
notify_test() ->
helpers:not_implemented().
%% @doc Given that start_link returned {ok, Player}. get_token shall always return a valid
%% player token. a valid token should be unique.
get_token_test() ->
helpers:not_implemented().
%% @doc Given that start_link returned {ok, Pid}. There shouldn't be possible to
%% execute this function with the same Player and Table arguments twice.
stop_test() ->
helpers:not_implemented().