OSDN Git Service

* [shogi-server]
[shogi-server/shogi-server.git] / test / TC_game_result.rb
1 $:.unshift File.join(File.dirname(__FILE__), "..")
2
3 require 'test/unit'
4 require 'shogi_server'
5 require 'shogi_server/game'
6
7 module ShogiServer
8   class BasicPlayer
9     attr_accessor :sente, :status
10   end
11 end
12
13 class TestGameResult < Test::Unit::TestCase
14   class DummyGame
15     attr_accessor :game_name
16   end
17
18   def setup
19     @p1 = ShogiServer::BasicPlayer.new
20     @p1.sente = true
21     @p2 = ShogiServer::BasicPlayer.new
22     @p2.sente = false
23     @game = DummyGame.new
24   end
25
26   def test_game_result_win
27     gr = ShogiServer::GameResultWin.new(@game, @p1, @p2)
28     assert_equal(@p1.last_game_win, true)
29     assert_equal(@p2.last_game_win, false)
30   end
31
32   def test_game_result_abnormal_win
33     gr = ShogiServer::GameResultAbnormalWin.new(@game, @p1, @p2)
34     assert_equal(@p1.last_game_win, true)
35     assert_equal(@p2.last_game_win, false)
36   end
37
38   def test_game_result_kachi_win
39     gr = ShogiServer::GameResultKachiWin.new(@game, @p1, @p2)
40     assert_equal(@p1.last_game_win, true)
41     assert_equal(@p2.last_game_win, false)
42   end
43
44   def test_game_result_illegal_kachi_win
45     gr = ShogiServer::GameResultIllegalKachiWin.new(@game, @p1, @p2)
46     assert_equal(@p1.last_game_win, true)
47     assert_equal(@p2.last_game_win, false)
48   end
49
50   def test_game_result_illegal_move_win
51     gr = ShogiServer::GameResultIllegalMoveWin.new(@game, @p1, @p2)
52     assert_equal(@p1.last_game_win, true)
53     assert_equal(@p2.last_game_win, false)
54   end
55
56   def test_game_result_uchifuzume_win
57     gr = ShogiServer::GameResultUchifuzumeWin.new(@game, @p1, @p2)
58     assert_equal(@p1.last_game_win, true)
59     assert_equal(@p2.last_game_win, false)
60   end
61
62   def test_game_result_oute_kaihi_more_win
63     gr = ShogiServer::GameResultOuteKaihiMoreWin.new(@game, @p1, @p2)
64     assert_equal(@p1.last_game_win, true)
65     assert_equal(@p2.last_game_win, false)
66   end
67
68   def test_game_result_outori_win
69     gr = ShogiServer::GameResultOutoriWin.new(@game, @p1, @p2)
70     assert_equal(@p1.last_game_win, true)
71     assert_equal(@p2.last_game_win, false)
72   end
73
74   def test_game_result_toryo_win
75     gr = ShogiServer::GameResultToryoWin.new(@game, @p1, @p2)
76     assert_equal(@p1.last_game_win, true)
77     assert_equal(@p2.last_game_win, false)
78   end
79
80   def test_game_result_oute_sennichite_win
81     gr = ShogiServer::GameResultOuteSennichiteWin.new(@game, @p1, @p2)
82     assert_equal(@p1.last_game_win, true)
83     assert_equal(@p2.last_game_win, false)
84   end
85
86   def test_game_result_draw
87     gr = ShogiServer::GameResultDraw.new(@game, @p1, @p2)
88     assert_equal(@p1.last_game_win, false)
89     assert_equal(@p2.last_game_win, false)
90   end
91
92   def test_game_result_sennichite_draw
93     gr = ShogiServer::GameResultSennichiteDraw.new(@game, @p1, @p2)
94     assert_equal(@p1.last_game_win, false)
95     assert_equal(@p2.last_game_win, false)
96   end
97
98 end
99