-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreed_player_test.rb
75 lines (59 loc) · 1.75 KB
/
greed_player_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require "greed_player"
require "dice_set"
require "fake_dice"
require "test/unit"
class GreedPlayerTest < Test::Unit::TestCase
def test_new_player_has_score_of_zero
fred = GreedPlayer.new
assert_equal 0, fred.score
end
def test_player_rolls_five_dice
george = GreedPlayer.new
dice = DiceSet.new
dice_roll = george.roll_dice(dice)
assert_equal 5, dice_roll.size
end
def test_player_can_keep_points_from_dice_roll
harry = GreedPlayer.new
dice = AllScoringDice.new
dice_roll = harry.roll_dice(dice)
harry.keep_points(dice_roll)
assert_equal 1200, harry.score
end
#should turns be a part of greed_game or greed_player?
=begin
def test_at_beginning_of_turn_temp_score_is_zero
end
def test_roll_of_zero_points_ends_turn_with_no_addition_to_score
end
=end
def test_player_can_select_which_dice_to_roll_again
mathilda = GreedPlayer.new
dice = SomeScoringDice.new
mathilda.roll_dice(dice)
second_roll = mathilda.roll_again(dice, [2,3,4])
assert_equal 3, second_roll.size
end
def test_leaving_unscoring_dice_out_of_second_roll_raises_error
geronimo = GreedPlayer.new
dice = SomeScoringDice.new
geronimo.roll_dice(dice)
assert_raises GreedPlayer::MustRollAllUnscoringDiceAgainError do
geronimo.roll_again(dice, [2,3])
end
end
def test_dice_not_selected_for_second_roll_are_added_to_temp_score
daisy = GreedPlayer.new
dice = SomeScoringDice.new
daisy.roll_dice(dice)
daisy.roll_again(dice, [2,3,4])
assert_equal 150, daisy.temp_score
end
def test_after_turn_ends_temp_score_is_reset_to_zero
duke = GreedPlayer.new
dice = SomeScoringDice.new
duke.roll_dice(dice)
duke.keep_points(dice)
assert_equal 0, duke.temp_score
end
end