Adds more BlockLocation tests

This commit is contained in:
Kristian Knarvik 2021-02-09 23:25:52 +01:00
parent 32410a82ba
commit f0a7ff8c47

View File

@ -4,7 +4,7 @@ import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.WorldMock;
import org.bukkit.Material;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -13,14 +13,13 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class BlockLocationTest {
private WorldMock mockWorld;
@Before
@BeforeEach
public void setUp() {
mockWorld = new WorldMock(Material.DIRT, 5);
}
@After
public void tearDown()
{
public void tearDown() {
MockBukkit.unmock();
}
@ -59,4 +58,27 @@ public class BlockLocationTest {
assertNotEquals(location1, location2);
}
@Test
public void makeRelativeTest() {
BlockLocation location = new BlockLocation(mockWorld, 3, 7, 19);
BlockLocation newLocation = location.makeRelative(34, 65, 75);
assertEquals(37, newLocation.getBlockX());
assertEquals(72, newLocation.getBlockY());
assertEquals(94, newLocation.getBlockZ());
}
@Test
public void materialTest() {
BlockLocation location = new BlockLocation(mockWorld, 0, 0, 0);
assertNotEquals(Material.BOOKSHELF, location.getType());
location.setType(Material.BOOKSHELF);
assertEquals(Material.BOOKSHELF, location.getType());
}
@Test
public void toStringTest() {
BlockLocation location = new BlockLocation(mockWorld, 56, 87, 34);
assertEquals("56,87,34", location.toString());
}
}