Legger til tester for partikkelklassen

This commit is contained in:
Kristian Knarvik 2020-03-23 12:35:39 +01:00
parent 27535beeb8
commit 693b9fb886

View File

@ -0,0 +1,52 @@
package inf112.fiasko.roborally.objects;
import inf112.fiasko.roborally.element_properties.Direction;
import inf112.fiasko.roborally.element_properties.ParticleType;
import inf112.fiasko.roborally.element_properties.TileType;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class ParticleTest {
private Particle particle;
private Particle particle2;
@Before
public void setUp() {
particle = new Particle(ParticleType.LASER_BEAM_SINGLE, Direction.NORTH);
particle2 = new Particle(ParticleType.LASER_BEAM_DOUBLE_CROSS, Direction.EAST);
}
@Test
public void getParticleTypeFromParticle() {
assertEquals(ParticleType.LASER_BEAM_SINGLE, particle.getParticleType());
}
@Test
public void getParticleTypeFromParticle2() {
assertEquals(ParticleType.LASER_BEAM_DOUBLE_CROSS, particle2.getParticleType());
}
@Test
public void getDirectionFromParticle() {
assertEquals(Direction.NORTH, particle.getDirection());
}
@Test
public void getDirectionFromParticle2() {
assertEquals(Direction.EAST, particle2.getDirection());
}
@Test
public void invalidParticleTypeIDReturnsNull() {
assertNull(ParticleType.getParticleTypeFromID(-1));
}
@Test (expected = IllegalArgumentException.class)
public void invalidParticleDirectionThrowsError() {
new Particle(ParticleType.LASER_BEAM_DOUBLE, Direction.NORTH_EAST);
}
}