Package ingsw.proj.cluedo.junittests

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

package ingsw.proj.cluedo.junittests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import ingsw.proj.cluedo.componenti.Casella;
import ingsw.proj.cluedo.componenti.Pedina;
import ingsw.proj.cluedo.componenti.StanzeEnum;
import ingsw.proj.cluedo.componenti.TipoCasellaEnum;

import java.awt.Point;

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

public class CasellaTest {

  private Casella casella;
  private Pedina pedina;
  private Casella.CasellaRidotta casellaPiccola;

  @Before
  public void setUp() throws Exception {
    casella = new Casella(StanzeEnum.BIBLIOTECA, new Point(3, 4));
    pedina = new Pedina(casella, "Ciao");
    casellaPiccola = casella.new CasellaRidotta("IoLaOccupo" ,new Point(3, 4), TipoCasellaEnum.NORMALE, StanzeEnum.BIBLIOTECA);
  }

  @After
  public void tearDown() throws Exception {
    casella = null;
    casellaPiccola = null;
    pedina = null;
    System.gc();
  }

  @Test
  public void testCasella() {
    assertTrue(casella instanceof Casella);
    assertNotNull(casella);
    assertNotNull(casellaPiccola);
  }

  @Test(expected = NullPointerException.class)
  public void testCasellaNull() {
    new Casella(null, new Point(3, 2));
    new Casella(StanzeEnum.CANTINA, new Point(-1,9));
    new Casella(StanzeEnum.BIBLIOTECA, null);
    casella.new CasellaRidotta(null,null,null,null);
    casella.setOccupante(pedina);
  }

  @Test
  public void testGetOccupante() {
    casella = new Casella(StanzeEnum.CANTINA, new Point(3, 3));
    assertNull(casella.getOccupante());
    casella.setOccupante(null);
    assertNull(casella.getOccupante());
    casella.setOccupante(pedina);
    assertNotNull(casella.getOccupante());
    assertSame(pedina, casella.getOccupante());
  }

  @Test
  public void testGetStanza() {
    assertTrue(casella.getStanza() instanceof StanzeEnum);
    assertNotNull(casella.getStanza());
  }

  @Test
  public void testSetOccupante() {
    casella.setOccupante(null);
    assertNull(casella.getOccupante());
    casella.setOccupante(pedina);
    assertNotNull(casella.getOccupante());
    assertSame(pedina, casella.getOccupante());
  }

}
TOP

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

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.