Search in sources :

Example 1 with IntRangeSetting

use of io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting in project Slimefun4 by Slimefun.

the class TestIntRangeSetting method testConstructorValidation.

@Test
@DisplayName("Test Constructor validation")
void testConstructorValidation() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_00", new CustomItemStack(Material.DIAMOND, "&cTest"));
    Assertions.assertThrows(IllegalArgumentException.class, () -> new IntRangeSetting(item, "test", min, -50, max));
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with IntRangeSetting

use of io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting in project Slimefun4 by Slimefun.

the class TestIntRangeSetting method testIllegalValues.

@Test
@DisplayName("Test illegal values")
void testIllegalValues() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST", new CustomItemStack(Material.DIAMOND, "&cTest"));
    IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max);
    item.addItemSetting(setting);
    item.register(plugin);
    Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(null));
    Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(-1));
    Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(101));
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with IntRangeSetting

use of io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting in project Slimefun4 by Slimefun.

the class TestIntRangeSetting method testMinMaxGetters.

@Test
@DisplayName("Test min and max getters")
void testMinMaxGetters() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_0", new CustomItemStack(Material.DIAMOND, "&cTest"));
    IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max);
    Assertions.assertEquals(min, setting.getMinimum());
    Assertions.assertEquals(max, setting.getMaximum());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with IntRangeSetting

use of io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting in project Slimefun4 by Slimefun.

the class TestIntRangeSetting method testAllowedValue.

@Test
@DisplayName("Test allowed value")
void testAllowedValue() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest"));
    IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max);
    item.addItemSetting(setting);
    item.register(plugin);
    Assertions.assertEquals(1, setting.getValue());
    setting.update(42);
    Assertions.assertEquals(42, setting.getValue());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)4 SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)4 DisplayName (org.junit.jupiter.api.DisplayName)4 Test (org.junit.jupiter.api.Test)4