mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
[CI skip] Added an extremely simple ResearchSetup test
This commit is contained in:
parent
a34abcb1e7
commit
1b951f77ea
@ -20,9 +20,17 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
*/
|
||||
public final class ResearchSetup {
|
||||
|
||||
private static boolean alreadyRan = false;
|
||||
|
||||
private ResearchSetup() {}
|
||||
|
||||
public static void setupResearches() {
|
||||
if (alreadyRan) {
|
||||
throw new UnsupportedOperationException("Researches can only be registered once!");
|
||||
}
|
||||
|
||||
alreadyRan = true;
|
||||
|
||||
register("walking_sticks", 0, "Walking Sticks", 1, SlimefunItems.GRANDMAS_WALKING_STICK, SlimefunItems.GRANDPAS_WALKING_STICK);
|
||||
register("portable_crafter", 1, "Portable Crafter", 1, SlimefunItems.PORTABLE_CRAFTER);
|
||||
register("fortune_cookie", 2, "Fortune Cookie", 1, SlimefunItems.FORTUNE_COOKIE);
|
||||
|
@ -0,0 +1,36 @@
|
||||
package io.github.thebusybiscuit.slimefun4.tests.researches;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
public class TestResearchSetup {
|
||||
|
||||
@BeforeAll
|
||||
public static void load() {
|
||||
MockBukkit.mock();
|
||||
MockBukkit.load(SlimefunPlugin.class);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void unload() {
|
||||
MockBukkit.unmock();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForExceptions() {
|
||||
// Not really ideal but still important to test.
|
||||
// Research amount is variable, so we can't test for that.
|
||||
// We are really only concerned about any runtime exceptions here.
|
||||
Assertions.assertDoesNotThrow(() -> ResearchSetup.setupResearches());
|
||||
|
||||
// Running it a second time should NOT be allowed.
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, () -> ResearchSetup.setupResearches());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user