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));
}
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));
}
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());
}
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());
}
Aggregations