X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=test%2FTC_floodgate.rb;h=c169b2670549ff4fa6ca9529f56b47d048bc54f9;hp=c53d9a1d28af69faf382075ee6ec2c99acd11977;hb=ce94a8dae6ddceb9b3af0b43d56da3d11062335e;hpb=09bf2bfc8b6a996083cb3283259caf364a71a356 diff --git a/test/TC_floodgate.rb b/test/TC_floodgate.rb index c53d9a1..c169b26 100644 --- a/test/TC_floodgate.rb +++ b/test/TC_floodgate.rb @@ -8,6 +8,15 @@ require 'test/mock_log_message' $topdir = File.expand_path File.dirname(__FILE__) +class SimplePlayer < ShogiServer::BasicPlayer + attr_accessor :status + def initialize + super + @status = "game_waiting" + @game_name = "floodgate-900-0" + end +end + class TestFloodgate < Test::Unit::TestCase def setup @fg = ShogiServer::League::Floodgate.new(nil) @@ -32,6 +41,37 @@ class TestFloodgate < Test::Unit::TestCase assert(fg.game_name?("floodgate-3600-0")) end + def test_select_players + league = ShogiServer::League.new(File.dirname(__FILE__)) + league.event = "test" + league.setup_players_database + + a = SimplePlayer.new + a.win = 1 + a.loss = 2 + a.rate = 0 + a.name = "a" + a.player_id = "a+123" + b = SimplePlayer.new + b.win = 10 + b.loss = 20 + b.rate = 1500 + b.name = "b" + b.player_id = "b+456" + c = SimplePlayer.new + c.win = 100 + c.loss = 200 + c.rate = 1000 + c.name = "c" + + league.add a + league.add b + league.add c + + fg = ShogiServer::League::Floodgate.new(league, {:game_name => "floodgate-900-0"}) + + assert_equal([a,b], fg.select_players) + end end class TestDeleteMostPlayingPlayer < Test::Unit::TestCase @@ -88,7 +128,8 @@ class TestMakeEven < Test::Unit::TestCase def test_match_odd players = [@a, @b, @c] @pairing.match(players) - assert_equal([@a, @b], players) + assert_equal(2, players.size) + assert(players[0] != players[1]) end end @@ -137,7 +178,10 @@ class TestRandomize < Test::Unit::TestCase def test_match players = [@a, @b, @c] @pairing.match(players) - assert_equal([@b,@a,@c], players) + assert_equal(3, players.size) + assert(players.include? @a) + assert(players.include? @b) + assert(players.include? @c) end end