package allumettes;
import org.junit.*;
import static org.junit.Assert.*;

/**
 * Classe de test de la classe JeuReel.
 * @author Édouard Lumet
 */
public class JeuReelTest {

	private JeuReel jeu;

	public static void main(String[] args) {
		org.junit.runner.JUnitCore.main(JeuReelTest.class.getName());
	}

    @Before
    public void setUp() {
        this.jeu = new JeuReel(13);
    }

    @Test
    public void testPriseMax() {
        assertEquals(3, JeuReel.PRISE_MAX);
    }

    @Test(expected = AssertionError.class)
    public void testConstructeur1() {
        new JeuReel(0);
    }

    @Test(expected = AssertionError.class)
    public void testConstructeur2() {
        new JeuReel(-1);
    }

    @Test(expected = CoupInvalideException.class)
    public void testRetirer1() throws Exception {
        this.jeu.retirer(-1);
    }

    @Test(expected = CoupInvalideException.class)
    public void testRetirer2() throws Exception {
        this.jeu.retirer(14);
    }

    @Test
    public void testRetirer3() throws Exception {
        assertEquals(13, this.jeu.getNombreAllumettes());
        this.jeu.retirer(3);
        assertEquals(10, this.jeu.getNombreAllumettes());
        this.jeu.retirer(2);
        assertEquals(8, this.jeu.getNombreAllumettes());
        this.jeu.retirer(3);
        assertEquals(5, this.jeu.getNombreAllumettes());
        this.jeu.retirer(1);
        assertEquals(4, this.jeu.getNombreAllumettes());
    }

}
