package ingsw.proj.cluedo.junittests;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import ingsw.proj.cluedo.componenti.Casella;
import ingsw.proj.cluedo.componenti.Stanza;
import ingsw.proj.cluedo.componenti.StanzeEnum;
import java.awt.Point;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class StanzaTest {
Stanza stanza;
ArrayList<Casella> caselle;
@Before
public void setUp() throws Exception {
caselle = new ArrayList<Casella>();
for (int i = 0; i < 4; i++) {
caselle.add(new Casella(StanzeEnum.CANTINA, new Point(i, i)));
}
stanza = new Stanza(StanzeEnum.CANTINA, caselle);
}
@After
public void tearDown() throws Exception {
stanza = null;
caselle = null;
System.gc();
}
@Test
public void testGetCasellaVuotaRandom() {
assertNotNull(stanza.getCasellaVuotaRandom());
assertNull(stanza.getCasellaVuotaRandom().getOccupante());
assertTrue(stanza.getCasellaVuotaRandom().getStanza().equals(StanzeEnum.CANTINA));
}
@Test
public void testStanza() {
caselle.clear();
for (int i = 0; i < 4; i++) {
caselle.add(new Casella(StanzeEnum.CORRIDOIO, new Point(i, i)));
}
stanza = new Stanza(StanzeEnum.CORRIDOIO, caselle);
assertTrue(stanza.getNome() == StanzeEnum.CORRIDOIO);
assertNotNull(stanza.getCaselle());
assertNotNull(stanza.getCasellaVuotaRandom());
}
@Test(expected = NullPointerException.class)
public void parametroNull() {
new Stanza(null, null);
new Stanza(null, caselle);
new Stanza(StanzeEnum.CAMERA_LETTO, null);
new Stanza(StanzeEnum.STUDIO, caselle);
}
}