1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
9 require 'interaction/match'
12 class TestMatch < Test::Unit::TestCase
14 @match = Match.new Game.get(:chess)
18 p1 = fake_player(:white)
19 p2 = fake_player(:black)
21 assert @match.register(p1)
22 assert ! @match.complete?
23 assert @match.register(p2)
24 assert @match.complete?
27 def test_register_twice
28 p1 = fake_player(:white)
30 assert @match.register(p1)
31 assert ! @match.complete?
32 assert ! @match.register(p1)
35 def test_register_multiple_players
36 p1 = fake_player(:white)
37 p2 = fake_player(:black)
38 p3 = fake_player(:white)
40 assert @match.register(p1)
41 assert @match.register(p2)
42 assert @match.complete?
43 assert !@match.register(p3)
47 p1 = fake_player(:white)
48 p2 = fake_player(:black)
50 assert @match.register(p1)
51 assert @match.register(p2)
53 assert @match.start(p2)
54 assert @match.start(p1)
56 assert @match.started?
59 def test_start_incomplete
60 p1 = fake_player(:white)
62 assert @match.register(p1)
63 assert !@match.start(p1)
67 p1 = fake_player(:white)
68 p2 = fake_player(:black)
80 player.metaclass_eval do
81 define_method(:color) { c }