๐Ÿ“ฆ robzwolf / tabula

๐Ÿ“„ DiceTestBasic.java ยท 64 lines
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
64import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Rule;
import org.junit.rules.Timeout;

import java.util.*;

public class DiceTestBasic {

    private Die d;
    private Dice ds;
    
    public DiceTestBasic(){

    }
    
    @Before
    public void setUp()
    {
	d = new Die();
	ds = new Dice();
    }

    @After
    public void tearDown()
    {
    }

    @Test(expected=NotRolledYetException.class)
    public void initially_die_not_rolled() throws Exception {
	d.getValue();
    }

    @Test(expected=NotRolledYetException.class)
    public void initially_dice_not_rolled() throws Exception {
	ds.getValues();
    }

    @Test
    public void set_seed_works_die() throws Exception{
	d.setSeed(1);
	d.roll();
	assertEquals(d.getValue(), 4);
	d.roll();
	assertEquals(d.getValue(), 5);
	d.roll();
	assertEquals(d.getValue(), 2);
    }

    @Test
    public void set_seed_works_dice() throws Exception{
	d.setSeed(1);
	ds.roll();
	assertEquals(ds.getValues().size(), 2);
	ds.roll();
	ds.roll();
	ds.roll();
	ds.roll();
	assertEquals(ds.getValues().size(), 4);
    }
}