OSDN Git Service

Provided more test cases for Monitor features.
[shogi-server/shogi-server.git] / test / TC_command.rb
index 973eea6..db3b333 100644 (file)
@@ -117,6 +117,11 @@ class TestFactoryMethod < Test::Unit::TestCase
     assert_instance_of(ShogiServer::MonitorOffCommand, cmd)
   end
 
+  def test_monitor2off_command
+    cmd = ShogiServer::Command.factory("%%MONITOR2OFF game_id", @p)
+    assert_instance_of(ShogiServer::Monitor2OffCommand, cmd)
+  end
+
   def test_help_command
     cmd = ShogiServer::Command.factory("%%HELP", @p)
     assert_instance_of(ShogiServer::HelpCommand, cmd)
@@ -498,6 +503,23 @@ end
 
 #
 #
+class TestMonitor2OffCommand < Test::Unit::TestCase 
+  def setup
+    @p = MockPlayer.new
+    @game = MockGame.new
+    @p.game = @game
+  end
+
+  def test_call
+    cmd = ShogiServer::Monitor2OffCommand.new("%%MONITOR2OFF hoge", @p, nil)
+    rc = cmd.call
+
+    assert_equal(:continue, rc)
+  end
+end
+
+#
+#
 class TestHelpCommand < Test::Unit::TestCase 
   def setup
     @p = MockPlayer.new
@@ -888,7 +910,7 @@ end
 #
 #
 class TestMonitorHandler < Test::Unit::TestCase
-  def test_not_equal
+  def test_not_equal_players
     @player1 = MockPlayer.new
     @handler1 = ShogiServer::MonitorHandler1.new @player1
     @player2 = MockPlayer.new
@@ -921,6 +943,15 @@ class TestMonitorHandler1 < Test::Unit::TestCase
   def test_header
     assert_equal("MONITOR", @handler.header)
   end
+  
+  def test_equal
+    assert_equal @handler, @handler
+    assert_not_equal @handler, nil
+  end
+
+  def test_not_equal
+    assert_not_equal(@handler, ShogiServer::MonitorHandler2.new(@player))
+  end
 
   def test_write_safe
     @handler.write_safe("game_id", "hoge")
@@ -945,6 +976,15 @@ class TestMonitorHandler2 < Test::Unit::TestCase
     assert_equal("MONITOR2", @handler.header)
   end
 
+  def test_equal
+    assert_equal @handler, @handler
+    assert_not_equal @handler, nil
+  end
+
+  def test_not_equal
+    assert_not_equal(@handler, ShogiServer::MonitorHandler1.new(@player))
+  end
+
   def test_write_safe
     @handler.write_safe("game_id", "hoge")
     assert_equal("##[MONITOR2][game_id] hoge\n##[MONITOR2][game_id] +OK\n",