1 $:.unshift File.join(File.dirname(__FILE__), "..")
2 $topdir = File.expand_path File.dirname(__FILE__)
6 require 'mock_log_message'
7 require 'test/mock_player'
8 require 'shogi_server/login'
9 require 'shogi_server/player'
10 require 'shogi_server/command'
16 @games["dummy_game_id"] = MockGame.new
24 $p1.status = "game_waiting"
28 $p2.status = "game_waiting"
41 return [MockPlayer.new]
52 def get_player(status, game_id, sente, searcher)
65 [$p1,$p2].each {|pp| yield pp}
68 def find_rival(player, game_name)
70 when nil # no preference
71 return get_player("game_waiting", game_name, nil, player)
72 when true # rival must be gote
73 return get_player("game_waiting", game_name, false, player)
74 when false # rival must be sente
75 return get_player("game_waiting", game_name, true, player)
83 class TestFactoryMethod < Test::Unit::TestCase
87 @p.name = "test_factory_method_player"
88 $league = MockLeague.new
91 def test_keep_alive_command
92 cmd = ShogiServer::Command.factory("", @p)
93 assert_instance_of(ShogiServer::KeepAliveCommand, cmd)
97 cmd = ShogiServer::Command.factory("+7776FU", @p)
98 assert_instance_of(ShogiServer::MoveCommand, cmd)
101 def test_special_command
102 cmd = ShogiServer::Command.factory("%TORYO", @p)
103 assert_instance_of(ShogiServer::SpecialCommand, cmd)
106 def test_special_command_timeout
107 cmd = ShogiServer::Command.factory(:timeout, @p)
108 assert_instance_of(ShogiServer::SpecialCommand, cmd)
111 def test_execption_command
112 cmd = ShogiServer::Command.factory(:exception, @p)
113 assert_instance_of(ShogiServer::ExceptionCommand, cmd)
116 def test_reject_command
117 cmd = ShogiServer::Command.factory("REJECT", @p)
118 assert_instance_of(ShogiServer::RejectCommand, cmd)
121 def test_agree_command
122 cmd = ShogiServer::Command.factory("AGREE", @p)
123 assert_instance_of(ShogiServer::AgreeCommand, cmd)
126 def test_show_command
127 cmd = ShogiServer::Command.factory("%%SHOW game_id", @p)
128 assert_instance_of(ShogiServer::ShowCommand, cmd)
131 def test_monitoron_command
132 cmd = ShogiServer::Command.factory("%%MONITORON game_id", @p)
133 assert_instance_of(ShogiServer::MonitorOnCommand, cmd)
136 def test_monitor2on_command
137 cmd = ShogiServer::Command.factory("%%MONITOR2ON game_id", @p)
138 assert_instance_of(ShogiServer::Monitor2OnCommand, cmd)
141 def test_monitoroff_command
142 cmd = ShogiServer::Command.factory("%%MONITOROFF game_id", @p)
143 assert_instance_of(ShogiServer::MonitorOffCommand, cmd)
146 def test_monitor2off_command
147 cmd = ShogiServer::Command.factory("%%MONITOR2OFF game_id", @p)
148 assert_instance_of(ShogiServer::Monitor2OffCommand, cmd)
151 def test_help_command
152 cmd = ShogiServer::Command.factory("%%HELP", @p)
153 assert_instance_of(ShogiServer::HelpCommand, cmd)
156 def test_rating_command
157 cmd = ShogiServer::Command.factory("%%RATING", @p)
158 assert_instance_of(ShogiServer::RatingCommand, cmd)
161 def test_version_command
162 cmd = ShogiServer::Command.factory("%%VERSION", @p)
163 assert_instance_of(ShogiServer::VersionCommand, cmd)
166 def test_game_command
167 cmd = ShogiServer::Command.factory("%%GAME", @p)
168 assert_instance_of(ShogiServer::GameCommand, cmd)
171 def test_game_challenge_command_game
172 cmd = ShogiServer::Command.factory("%%GAME default-1500-0 +", @p)
173 assert_instance_of(ShogiServer::GameChallengeCommand, cmd)
176 def test_game_challenge_command_challenge
177 cmd = ShogiServer::Command.factory("%%CHALLENGE default-1500-0 -", @p)
178 assert_instance_of(ShogiServer::GameChallengeCommand, cmd)
181 def test_chat_command
182 cmd = ShogiServer::Command.factory("%%CHAT hello", @p)
183 assert_instance_of(ShogiServer::ChatCommand, cmd)
186 def test_list_command
187 cmd = ShogiServer::Command.factory("%%LIST", @p)
188 assert_instance_of(ShogiServer::ListCommand, cmd)
192 cmd = ShogiServer::Command.factory("%%WHO", @p)
193 assert_instance_of(ShogiServer::WhoCommand, cmd)
196 def test_logout_command
197 cmd = ShogiServer::Command.factory("LOGOUT", @p)
198 assert_instance_of(ShogiServer::LogoutCommand, cmd)
201 def test_challenge_command
202 cmd = ShogiServer::Command.factory("CHALLENGE", @p)
203 assert_instance_of(ShogiServer::ChallengeCommand, cmd)
206 def test_space_command
207 cmd = ShogiServer::Command.factory(" ", @p)
208 assert_instance_of(ShogiServer::SpaceCommand, cmd)
211 def test_setbuoy_command
212 cmd = ShogiServer::Command.factory("%%SETBUOY buoy_test-1500-0 +7776FU", @p)
213 assert_instance_of(ShogiServer::SetBuoyCommand, cmd)
216 def test_setbuoy_command_with_counter
217 cmd = ShogiServer::Command.factory("%%SETBUOY buoy_test-1500-0 +7776FU 3", @p)
218 assert_instance_of(ShogiServer::SetBuoyCommand, cmd)
221 def test_deletebuoy_command
222 cmd = ShogiServer::Command.factory("%%DELETEBUOY buoy_test-1500-0", @p)
223 assert_instance_of(ShogiServer::DeleteBuoyCommand, cmd)
226 def test_getbuoycount_command
227 cmd = ShogiServer::Command.factory("%%GETBUOYCOUNT buoy_test-1500-0", @p)
228 assert_instance_of(ShogiServer::GetBuoyCountCommand, cmd)
231 def test_fork_command
232 cmd = ShogiServer::Command.factory("%%FORK server-denou-14400-60+p1+p2+20130223185013 buoy_denou-14400-60", @p)
233 assert_instance_of(ShogiServer::ForkCommand, cmd)
236 def test_fork_command2
237 cmd = ShogiServer::Command.factory("%%FORK server-denou-14400-60+p1+p2+20130223185013", @p)
238 assert_instance_of(ShogiServer::ForkCommand, cmd)
241 def test_void_command
242 cmd = ShogiServer::Command.factory("%%%HOGE", @p)
243 assert_instance_of(ShogiServer::VoidCommand, cmd)
247 cmd = ShogiServer::Command.factory("should_be_error", @p)
248 assert_instance_of(ShogiServer::ErrorCommand, cmd)
250 assert_match /unknown command: should_be_error/, cmd.msg
254 cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p)
255 assert_instance_of(ShogiServer::ErrorCommand, cmd)
257 assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
259 cmd = ShogiServer::Command.factory("LOGin hoge foo", @p)
260 assert_instance_of(ShogiServer::ErrorCommand, cmd)
262 assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
264 cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p)
265 assert_instance_of(ShogiServer::ErrorCommand, cmd)
267 assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
269 cmd = ShogiServer::Command.factory("LOGINhoge foo", @p)
270 assert_instance_of(ShogiServer::ErrorCommand, cmd)
272 assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg
278 class TestKeepAliveCommand < Test::Unit::TestCase
284 cmd = ShogiServer::KeepAliveCommand.new("", @p)
286 assert_equal(:continue, rc)
292 class TestMoveCommand < Test::Unit::TestCase
301 cmd = ShogiServer::MoveCommand.new("+7776FU", @p)
303 assert_equal(:continue, rc)
307 cmd = ShogiServer::MoveCommand.new("+7776FU,'comment", @p)
309 assert_equal(:continue, rc)
310 assert_equal("'*comment", @game.log.first)
314 @game.finish_flag = true
315 @p.protocol = ShogiServer::LoginCSA::PROTOCOL
316 cmd = ShogiServer::MoveCommand.new("+7776FU", @p)
318 assert_equal(:return, rc)
324 class TestSpecialComand < Test::Unit::TestCase
333 @game.finish_flag = true
334 cmd = ShogiServer::SpecialCommand.new("%TORYO", @p)
336 assert_equal(:continue, rc)
339 def test_toryo_csa_protocol
340 @game.finish_flag = true
341 @p.protocol = ShogiServer::LoginCSA::PROTOCOL
342 cmd = ShogiServer::SpecialCommand.new("%TORYO", @p)
344 assert_equal(:return, rc)
348 cmd = ShogiServer::SpecialCommand.new(:timeout, @p)
350 assert_equal(:continue, rc)
353 def test_expired_game
354 @p.status = "agree_waiting"
355 @game.prepared_expire = true
356 assert(!@game.rejected)
357 cmd = ShogiServer::SpecialCommand.new(:timeout, @p)
359 assert_equal(:continue, rc)
360 assert(@game.rejected)
363 def test_expired_game_csa_protocol
364 @p.protocol = ShogiServer::LoginCSA::PROTOCOL
365 @p.status = "agree_waiting"
366 @game.prepared_expire = true
367 assert(!@game.rejected)
368 cmd = ShogiServer::SpecialCommand.new(:timeout, @p)
370 assert_equal(:return, rc)
371 assert(@game.rejected)
375 @p.status = "should_be_ignored"
376 cmd = ShogiServer::SpecialCommand.new(:timeout, @p)
378 assert_equal(:continue, rc)
384 class TestExceptionCommand < Test::Unit::TestCase
390 cmd = ShogiServer::ExceptionCommand.new(:exception, @p)
392 assert_equal(:return, rc)
398 class TestRejectCommand < Test::Unit::TestCase
407 @p.status = "agree_waiting"
408 assert(!@game.rejected)
409 cmd = ShogiServer::RejectCommand.new("REJECT", @p)
412 assert_equal(:continue, rc)
413 assert(@game.rejected)
416 def test_call_csa_protocol
417 @p.protocol = ShogiServer::LoginCSA::PROTOCOL
418 @p.status = "agree_waiting"
419 assert(!@game.rejected)
420 cmd = ShogiServer::RejectCommand.new("REJECT", @p)
423 assert_equal(:return, rc)
424 assert(@game.rejected)
428 @p.status = "should_be_ignored"
429 cmd = ShogiServer::RejectCommand.new("REJECT", @p)
432 assert_equal(:continue, rc)
433 assert(!@game.rejected)
439 class TestAgreeCommand < Test::Unit::TestCase
444 @p.status = "agree_waiting"
447 def test_not_start_yet
448 cmd = ShogiServer::AgreeCommand.new("AGREE", @p)
450 assert_equal(:continue, rc)
451 assert(!@game.started)
455 @game.is_startable_status = true
456 cmd = ShogiServer::AgreeCommand.new("AGREE", @p)
458 assert_equal(:continue, rc)
459 assert(@game.started)
463 @p.status = "should_be_ignored"
464 cmd = ShogiServer::AgreeCommand.new("AGREE", @p)
466 assert_equal(:continue, rc)
467 assert(!@game.started)
473 class TestShowCommand < Test::Unit::TestCase
481 cmd = ShogiServer::ShowCommand.new("%%SHOW hoge", @p, @game)
484 assert_equal(:continue, rc)
487 def test_call_nil_game
488 cmd = ShogiServer::ShowCommand.new("%%SHOW hoge", @p, nil)
491 assert_equal(:continue, rc)
497 class TestMonitorOnCommand < Test::Unit::TestCase
505 cmd = ShogiServer::MonitorOnCommand.new("%%MONITORON hoge", @p, nil)
508 assert_equal(:continue, rc)
511 def test_call_read_logfile
513 cmd = ShogiServer::MonitorOnCommand.new("%%MONITORON hoge", @p, game)
515 assert_equal("##[MONITOR][dummy_game_id] dummy_game_show\n##[MONITOR][dummy_game_id] line1\n##[MONITOR][dummy_game_id] line2\n##[MONITOR][dummy_game_id] +OK\n", @p.out.join)
516 assert_equal(:continue, rc)
522 class TestMonitor2OnCommand < Test::Unit::TestCase
530 cmd = ShogiServer::Monitor2OnCommand.new("%%MONITOR2ON hoge", @p, nil)
533 assert_equal(:continue, rc)
536 def test_call_read_logfile
537 $tempfile = Tempfile.new("TC_command_test_call_read_logfile")
538 $tempfile.write "hoge\nfoo\n"
544 cmd = ShogiServer::Monitor2OnCommand.new("%%MONITOR2ON hoge", @p, game)
546 assert_equal("##[MONITOR2][dummy_game_id] hoge\n##[MONITOR2][dummy_game_id] foo\n##[MONITOR2][dummy_game_id] +OK\n", @p.out.join)
547 assert_equal(:continue, rc)
554 class TestMonitorOffCommand < Test::Unit::TestCase
562 cmd = ShogiServer::MonitorOffCommand.new("%%MONITOROFF hoge", @p, nil)
565 assert_equal(:continue, rc)
571 class TestMonitor2OffCommand < Test::Unit::TestCase
579 cmd = ShogiServer::Monitor2OffCommand.new("%%MONITOR2OFF hoge", @p, nil)
582 assert_equal(:continue, rc)
588 class TestHelpCommand < Test::Unit::TestCase
596 cmd = ShogiServer::HelpCommand.new("%%HELP", @p)
599 assert_equal(:continue, rc)
605 class TestRatingCommand < Test::Unit::TestCase
613 players = [MockPlayer.new]
614 cmd = ShogiServer::RatingCommand.new("%%RATING", @p, players)
617 assert_equal(:continue, rc)
623 class TestVersionCommand < Test::Unit::TestCase
631 cmd = ShogiServer::VersionCommand.new("%%VERSION", @p)
634 assert_equal(:continue, rc)
640 class TestGameCommand < Test::Unit::TestCase
647 def test_call_connected
648 @p.status = "connected"
649 cmd = ShogiServer::GameCommand.new("%%GAME", @p)
652 assert_equal(:continue, rc)
653 assert_equal("connected", @p.status)
656 def test_call_game_waiting
657 @p.status = "game_waiting"
658 cmd = ShogiServer::GameCommand.new("%%GAME", @p)
661 assert_equal(:continue, rc)
662 assert_equal("connected", @p.status)
665 def test_call_agree_waiting
666 @p.status = "agree_waiting"
667 cmd = ShogiServer::GameCommand.new("%%GAME", @p)
670 assert_equal(:continue, rc)
671 assert_equal("agree_waiting", @p.status)
677 class TestChatCommand < Test::Unit::TestCase
685 players = [["dummy_name", MockPlayer.new]]
686 cmd = ShogiServer::ChatCommand.new("%%CHAT hoge", @p, "dummy message", players)
689 assert_equal(:continue, rc)
692 def test_call_csa_protocol
693 players = [["dummy_name", MockPlayer.new]]
694 players.each do |name, p|
695 p.protocol = ShogiServer::LoginCSA::PROTOCOL
697 cmd = ShogiServer::ChatCommand.new("%%CHAT hoge", @p, "dummy message", players)
700 assert_equal(:continue, rc)
706 class TestListCommand < Test::Unit::TestCase
714 games = [["dummy_game_id", MockGame.new]]
715 cmd = ShogiServer::ListCommand.new("%%LIST", @p, games)
718 assert_equal(:continue, rc)
725 class TestWhoCommand < Test::Unit::TestCase
733 players = [["dummy_name", MockPlayer.new]]
734 cmd = ShogiServer::WhoCommand.new("%%LIST", @p, players)
737 assert_equal(:continue, rc)
744 class TestLogoutCommand < Test::Unit::TestCase
752 cmd = ShogiServer::LogoutCommand.new("LOGOUT", @p)
755 assert_equal(:return, rc)
762 class TestChallengeCommand < Test::Unit::TestCase
769 cmd = ShogiServer::ChallengeCommand.new("CHALLENGE", @p)
772 assert_equal(:continue, rc)
778 class TestSpaceCommand < Test::Unit::TestCase
785 cmd = ShogiServer::SpaceCommand.new("", @p)
788 assert_equal(:continue, rc)
794 class TestErrorCommand < Test::Unit::TestCase
801 cmd = ShogiServer::ErrorCommand.new("", @p)
804 assert_equal(:continue, rc)
808 class BaseTestBuoyCommand < Test::Unit::TestCase
811 $league = MockLeague.new
814 @buoy = ShogiServer::Buoy.new
822 file = File.join($topdir, "buoy.yaml")
823 File.delete file if File.exist? file
834 class TestSetBuoyCommand < BaseTestBuoyCommand
838 @p.name = "set_buoy_player"
842 assert @buoy.is_new_game?("buoy_hoge-1500-0")
843 cmd = ShogiServer::SetBuoyCommand.new "%%SETBUOY", @p, "buoy_hoge-1500-0", "+7776FU", 2
846 assert !@buoy.is_new_game?("buoy_hoge-1500-0")
847 assert !$p1.out.empty?
848 assert !$p2.out.empty?
849 buoy_game2 = @buoy.get_game("buoy_hoge-1500-0")
850 assert_equal ShogiServer::BuoyGame.new("buoy_hoge-1500-0", "+7776FU", @p.name, 1), buoy_game2
854 assert @buoy.is_new_game?("buoy_hoge-1500-0")
855 cmd = ShogiServer::SetBuoyCommand.new "%%SETBUOY", @p, "buoy_hoge-1500-0", "+7776FU", 1
858 assert @buoy.is_new_game?("buoy_hoge-1500-0")
859 assert !$p1.out.empty?
860 assert !$p2.out.empty?
863 def test_call_error_not_buoy_game_name
864 assert @buoy.is_new_game?("buoy_hoge-1500-0")
865 cmd = ShogiServer::SetBuoyCommand.new "%%SETBUOY", @p, "buoyhoge-1500-0", "+7776FU", 1
868 assert $p1.out.empty?
869 assert $p2.out.empty?
870 assert @buoy.is_new_game?("buoy_hoge-1500-0")
873 def test_call_error_duplicated_game_name
874 assert @buoy.is_new_game?("buoy_duplicated-1500-0")
875 bg = ShogiServer::BuoyGame.new("buoy_duplicated-1500-0", ["+7776FU"], @p.name, 1)
877 assert !@buoy.is_new_game?("buoy_duplicated-1500-0")
879 cmd = ShogiServer::SetBuoyCommand.new "%%SETBUOY", @p, "buoy_duplicated-1500-0", "+7776FU", 1
882 assert $p1.out.empty?
883 assert $p2.out.empty?
884 assert !@buoy.is_new_game?("buoy_duplicated-1500-0")
887 def test_call_error_bad_moves
888 assert @buoy.is_new_game?("buoy_badmoves-1500-0")
889 cmd = ShogiServer::SetBuoyCommand.new "%%SETBUOY", @p, "buoy_badmoves-1500-0", "+7776FU+8786FU", 1
892 assert $p1.out.empty?
893 assert $p2.out.empty?
894 assert @buoy.is_new_game?("buoy_badmoves-1500-0")
897 def test_call_error_bad_counter
898 assert @buoy.is_new_game?("buoy_badcounter-1500-0")
899 cmd = ShogiServer::SetBuoyCommand.new "%%SETBUOY", @p, "buoy_badcounter-1500-0", "+7776FU", 0
902 assert $p1.out.empty?
903 assert $p2.out.empty?
904 assert @buoy.is_new_game?("buoy_badcounter-1500-0")
911 class TestDeleteBuoyCommand < BaseTestBuoyCommand
913 buoy_game = ShogiServer::BuoyGame.new("buoy_testdeletebuoy-1500-0", "+7776FU", @p.name, 1)
914 assert @buoy.is_new_game?(buoy_game.game_name)
915 @buoy.add_game buoy_game
916 assert !@buoy.is_new_game?(buoy_game.game_name)
917 cmd = ShogiServer::DeleteBuoyCommand.new "%%DELETEBUOY", @p, buoy_game.game_name
920 assert $p1.out.empty?
921 assert $p2.out.empty?
922 assert @buoy.is_new_game?(buoy_game.game_name)
925 def test_call_not_exist
926 buoy_game = ShogiServer::BuoyGame.new("buoy_notexist-1500-0", "+7776FU", @p.name, 1)
927 assert @buoy.is_new_game?(buoy_game.game_name)
928 cmd = ShogiServer::DeleteBuoyCommand.new "%%DELETEBUOY", @p, buoy_game.game_name
931 assert $p1.out.empty?
932 assert $p2.out.empty?
933 assert @buoy.is_new_game?(buoy_game.game_name)
936 def test_call_another_player
937 buoy_game = ShogiServer::BuoyGame.new("buoy_anotherplayer-1500-0", "+7776FU", "another_player", 1)
938 assert @buoy.is_new_game?(buoy_game.game_name)
939 @buoy.add_game(buoy_game)
940 assert !@buoy.is_new_game?(buoy_game.game_name)
942 cmd = ShogiServer::DeleteBuoyCommand.new "%%DELETEBUOY", @p, buoy_game.game_name
945 assert_equal "##[ERROR] you are not allowed to delete a buoy game that you did not set: buoy_anotherplayer-1500-0\n", @p.out.first
946 assert !@buoy.is_new_game?(buoy_game.game_name)
952 class TestForkCommand < Test::Unit::TestCase
954 @player = MockPlayer.new
957 def test_new_buoy_game_name
958 src = "%%FORK server+denou-14400-60+p1+p2+20130223185013"
959 c = ShogiServer::ForkCommand.new src, @player, "server+denou-14400-60+p1+p2+20130223185013", nil, 13
960 c.decide_new_buoy_game_name
961 assert_equal "buoy_denou_13-14400-60", c.new_buoy_game
964 def test_new_buoy_game_name2
965 src = "%%FORK server+denou-14400-060+p1+p2+20130223185013"
966 c = ShogiServer::ForkCommand.new src, @player, "server+denou-14400-060+p1+p2+20130223185013", nil, 13
967 c.decide_new_buoy_game_name
968 assert_equal "buoy_denou_13-14400-060", c.new_buoy_game
974 class TestGetBuoyCountCommand < BaseTestBuoyCommand
976 buoy_game = ShogiServer::BuoyGame.new("buoy_testdeletebuoy-1500-0", "+7776FU", @p.name, 1)
977 assert @buoy.is_new_game?(buoy_game.game_name)
978 @buoy.add_game buoy_game
979 assert !@buoy.is_new_game?(buoy_game.game_name)
980 cmd = ShogiServer::GetBuoyCountCommand.new "%%GETBUOYCOUNT", @p, buoy_game.game_name
983 assert_equal ["##[GETBUOYCOUNT] 1\n", "##[GETBUOYCOUNT] +OK\n"], @p.out
986 def test_call_not_exist
987 buoy_game = ShogiServer::BuoyGame.new("buoy_notexist-1500-0", "+7776FU", @p.name, 1)
988 assert @buoy.is_new_game?(buoy_game.game_name)
989 cmd = ShogiServer::GetBuoyCountCommand.new "%%GETBUOYCOUNT", @p, buoy_game.game_name
992 assert_equal ["##[GETBUOYCOUNT] -1\n", "##[GETBUOYCOUNT] +OK\n"], @p.out
998 class TestMonitorHandler < Test::Unit::TestCase
999 def test_not_equal_players
1000 @player1 = MockPlayer.new
1001 @handler1 = ShogiServer::MonitorHandler1.new @player1
1002 @player2 = MockPlayer.new
1003 @handler2 = ShogiServer::MonitorHandler1.new @player2
1005 assert_not_equal(@handler1, @handler2)
1009 @player1 = MockPlayer.new
1010 @handler1 = ShogiServer::MonitorHandler1.new @player1
1011 @handler2 = ShogiServer::MonitorHandler1.new @player1
1013 assert_equal(@handler1, @handler2)
1019 class TestMonitorHandler1 < Test::Unit::TestCase
1021 @player = MockPlayer.new
1022 @handler = ShogiServer::MonitorHandler1.new @player
1026 assert_equal(1, @handler.type)
1030 assert_equal("MONITOR", @handler.header)
1034 assert_equal @handler, @handler
1035 assert_not_equal @handler, nil
1039 assert_not_equal(@handler, ShogiServer::MonitorHandler2.new(@player))
1043 @handler.write_safe("game_id", "hoge")
1044 assert_equal("##[MONITOR][game_id] hoge\n##[MONITOR][game_id] +OK\n",
1051 class TestMonitorHandler2 < Test::Unit::TestCase
1053 @player = MockPlayer.new
1054 @handler = ShogiServer::MonitorHandler2.new @player
1058 assert_equal(2, @handler.type)
1062 assert_equal("MONITOR2", @handler.header)
1066 assert_equal @handler, @handler
1067 assert_not_equal @handler, nil
1071 assert_not_equal(@handler, ShogiServer::MonitorHandler1.new(@player))
1075 @handler.write_safe("game_id", "hoge")
1076 assert_equal("##[MONITOR2][game_id] hoge\n##[MONITOR2][game_id] +OK\n",
1080 def test_write_safe2
1081 @handler.write_safe("game_id", "hoge\nfoo")
1082 assert_equal("##[MONITOR2][game_id] hoge\n##[MONITOR2][game_id] foo\n##[MONITOR2][game_id] +OK\n",