|
| 1 | +Class { |
| 2 | + #name : #DieHandleTest, |
| 3 | + #superclass : #ExercismTest, |
| 4 | + #category : #'Exercise@Die' |
| 5 | +} |
| 6 | + |
| 7 | +{ #category : #tests } |
| 8 | +DieHandleTest >> testAddingTwiceTheSameDice [ |
| 9 | + | handle | |
| 10 | + handle := DieHandle new. |
| 11 | + handle addDie: (Die withFaces: 6). |
| 12 | + self assert: handle diceNumber equals: 1. |
| 13 | + handle addDie: (Die withFaces: 6). |
| 14 | + self assert: handle diceNumber equals: 2. |
| 15 | +] |
| 16 | + |
| 17 | +{ #category : #tests } |
| 18 | +DieHandleTest >> testCreationAdding [ |
| 19 | + | handle | |
| 20 | + handle := DieHandle new |
| 21 | + addDie: (Die withFaces: 6); |
| 22 | + addDie: (Die withFaces: 10); |
| 23 | + yourself. |
| 24 | + self assert: handle diceNumber equals: 2. |
| 25 | +] |
| 26 | + |
| 27 | +{ #category : #tests } |
| 28 | +DieHandleTest >> testRoll [ |
| 29 | + |
| 30 | + | handle | |
| 31 | + handle := DieHandle new |
| 32 | + addDie: (Die withFaces: 6); |
| 33 | + addDie: (Die withFaces: 10); |
| 34 | + yourself. |
| 35 | + 1000 timesRepeat: [ handle roll between: 2 and: 16 ] |
| 36 | +] |
| 37 | + |
| 38 | +{ #category : #tests } |
| 39 | +DieHandleTest >> testSimpleHandle [ |
| 40 | + self assert: 2 D20 diceNumber equals: 2. |
| 41 | +] |
| 42 | + |
| 43 | +{ #category : #tests } |
| 44 | +DieHandleTest >> testSumming [ |
| 45 | + |
| 46 | + | handle | |
| 47 | + handle := 2 D20 + 3 D10. |
| 48 | + self assert: handle diceNumber equals: 5. |
| 49 | +] |
| 50 | + |
| 51 | +{ #category : #tests } |
| 52 | +DieHandleTest >> testSummingAndRolling [ |
| 53 | + |
| 54 | + | handle | |
| 55 | + handle := 2 D20 + 3 D10. |
| 56 | + self assert: handle diceNumber equals: 5. |
| 57 | + 100 timesRepeat: |
| 58 | + [ handle roll between: 5 and: 70 ] |
| 59 | +] |
0 commit comments