From f0a7ff8c474cb4bf73801c7c463e2e575486db8a Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Tue, 9 Feb 2021 23:25:52 +0100 Subject: [PATCH] Adds more BlockLocation tests --- .../knarcraft/stargate/BlockLocationTest.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/test/java/net/knarcraft/stargate/BlockLocationTest.java b/src/test/java/net/knarcraft/stargate/BlockLocationTest.java index bc603f6..72b64c9 100644 --- a/src/test/java/net/knarcraft/stargate/BlockLocationTest.java +++ b/src/test/java/net/knarcraft/stargate/BlockLocationTest.java @@ -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()); + } + }