Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added unbind test with functionality to pass the test

  • Loading branch information...
commit 24b3b1b2606da26f98112d3ba7df584de8f19bf8 1 parent 30840d3
Gianfranco Alongi authored
Showing with 18 additions and 1 deletion.
  1. +6 −1 Two/Solution/src/server.erl
  2. +12 −0 Two/Solution/test/server_tests.erl
7 Two/Solution/src/server.erl
View
@@ -59,4 +59,9 @@ perform_command(#binding{type = bind,arguments = Args},State) ->
Type = proplists:get_value(type,Args),
File = proplists:get_value(file,Args),
Bindings = State#state.bindings,
- {"binding created",State#state{bindings = [{Type,File}|Bindings]}}.
+ {"binding created",State#state{bindings = [{Type,File}|Bindings]}};
+perform_command(#binding{type = unbind,arguments = Args},State) ->
+ Type = proplists:get_value(type,Args),
+ Bindings = [{T,F} || {T,F} <- State#state.bindings,T =/= Type],
+ {"binding undone",State#state{bindings = Bindings}}.
+
12 Two/Solution/test/server_tests.erl
View
@@ -30,6 +30,18 @@ server_bind_type_file_test() ->
?assertEqual("bindings:\n"
" testtype, compilation_clean_module",ListRes),
server:stop(CommandPort).
+
+server_unbind_type_test() ->
+ CommandPort = 50001,
+ Options = [{files,"./test/test_files/"},
+ {command_port,CommandPort}],
+ server:start(Options),
+ send_receive_command(CommandPort,"bind testtype compilation_clean_module"),
+ ?assertEqual("binding undone",send_receive_command(CommandPort,"unbind testtype")),
+ ListRes = send_receive_command(CommandPort,"list bind"),
+ ?assertEqual("bindings: none",ListRes),
+ server:stop(CommandPort).
+
%% --------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.