diff options
Diffstat (limited to 'pharo-mooc/redo/src/Dice/DieHandleTest.class.st')
| -rw-r--r-- | pharo-mooc/redo/src/Dice/DieHandleTest.class.st | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/pharo-mooc/redo/src/Dice/DieHandleTest.class.st b/pharo-mooc/redo/src/Dice/DieHandleTest.class.st new file mode 100644 index 0000000..ac6bc55 --- /dev/null +++ b/pharo-mooc/redo/src/Dice/DieHandleTest.class.st @@ -0,0 +1,61 @@ +Class { + #name : #DieHandleTest, + #superclass : #TestCase, + #category : #Dice +} + +{ #category : #tests } +DieHandleTest >> testCreationAndAdding [ + + | handle | + handle := DieHandle new + addDie: (Die withFaces: 6); + addDie: (Die withFaces: 10); + yourself. + self assert: handle diceNumber equals: 2 +] + +{ #category : #tests } +DieHandleTest >> testCreationWithTheSameDice [ + + | handle | + handle := DieHandle new addDie: (Die withFaces: 6). + self assert: handle diceNumber equals: 1. + handle addDie: (Die withFaces: 6). + self assert: handle diceNumber equals: 2. +] + +{ #category : #tests } +DieHandleTest >> testMaxValue [ + + | handle | + handle := DieHandle new + addDie: (Die withFaces: 6); + addDie: (Die withFaces: 10); + yourself. + self assert: handle maxValue equals: 16 +] + +{ #category : #tests } +DieHandleTest >> testRoll [ + + | handle | + handle := DieHandle new + addDie: (Die withFaces: 6); + addDie: (Die withFaces: 10); + yourself. + 10 timesRepeat: + [ self assert: (handle roll between: handle diceNumber and: handle maxValue) ] +] + +{ #category : #tests } +DieHandleTest >> testSimpleHandle [ + + self assert: 2 D20 equals: 2 +] + +{ #category : #tests } +DieHandleTest >> testSumming [ + + self assert: (3 D4 + 2 D6) diceNumber equals: 5 +] |
