Package ingsw.proj.cluedo.junittests

Source Code of ingsw.proj.cluedo.junittests.TabelloneTest

package ingsw.proj.cluedo.junittests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import ingsw.proj.cluedo.componenti.Casella;
import ingsw.proj.cluedo.componenti.Stanza;
import ingsw.proj.cluedo.componenti.StanzeEnum;
import ingsw.proj.cluedo.componenti.Tabellone;

import java.awt.Point;
import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class TabelloneTest {

  Casella[][] tabellone;
  ArrayList<Stanza> stanze;
  ArrayList<Casella> caselle;
  Stanza stanza;
  Tabellone tab;

  @Before
  public void setUp() throws Exception {
    tabellone = new Casella[4][4];
    caselle = new ArrayList<Casella>();
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        tabellone[i][i] = new Casella(StanzeEnum.BIBLIOTECA, new Point(i, j));
    stanze = new ArrayList<Stanza>();
    for (int i = 0; i < 4; i++) {
      caselle.add(new Casella(StanzeEnum.CANTINA, new Point(i, i)));
    }
    stanza = new Stanza(StanzeEnum.CANTINA, caselle);
    stanze.add(stanza);
    caselle.clear();
    for (int i = 0; i < 4; i++) {
      caselle.add(new Casella(StanzeEnum.BAGNO, new Point(i, i)));
    }
    stanza = new Stanza(StanzeEnum.BAGNO, caselle);
    stanze.add(stanza);

    tab = new Tabellone(tabellone, stanze);

  }

  @Test
  public void testTabellone() {
    assertNull(tab.getCasella(new Point(5, 5)));
    assertNotNull(tab.getCasella(new Point(1, 1)));
    assertNull(tab.getCasellaVuotaInStanza(StanzeEnum.CUCINA));
    assertNotNull(tab.getCasellaVuotaInStanza(StanzeEnum.BAGNO));
    assertNotNull(tab.getCasella(new Point(1, 1)));
    assertNull(tab.getCasella(new Point(5, 5)));
  }

  @Test(expected = NullPointerException.class)
  public void riferimentiNull() {
    new Tabellone(null, null);
    new Tabellone(null, stanze);
    new Tabellone(tabellone, null);
  }

  @After
  public void tearDown() throws Exception {
    tabellone = null;
    stanze = null;
    caselle = null;
    stanza = null;
    tab = null;
    System.gc();
  }

}
TOP

Related Classes of ingsw.proj.cluedo.junittests.TabelloneTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.