use of io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting in project Slimefun4 by Slimefun.
the class TestDoubleRangeSetting method testConstructorValidation.
@Test
@DisplayName("Test Constructor validation")
void testConstructorValidation() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_00", new CustomItemStack(Material.DIAMOND, "&cTest"));
Assertions.assertThrows(IllegalArgumentException.class, () -> new DoubleRangeSetting(item, "test", min, -1.0, max));
}
use of io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting in project Slimefun4 by Slimefun.
the class TestDoubleRangeSetting method testAllowedValue.
@Test
@DisplayName("Test allowed value")
void testAllowedValue() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest"));
DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.25, max);
item.addItemSetting(setting);
item.register(plugin);
Assertions.assertEquals(0.25, setting.getValue());
setting.update(0.75);
Assertions.assertEquals(0.75, setting.getValue());
}
use of io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting in project Slimefun4 by Slimefun.
the class TestDoubleRangeSetting method testMinMaxGetters.
@Test
@DisplayName("Test min and max getters")
void testMinMaxGetters() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_0", new CustomItemStack(Material.DIAMOND, "&cTest"));
DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.5, max);
Assertions.assertEquals(min, setting.getMinimum());
Assertions.assertEquals(max, setting.getMaximum());
}
use of io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting in project Slimefun4 by Slimefun.
the class TestDoubleRangeSetting method testIllegalValues.
@Test
@DisplayName("Test illegal values")
void testIllegalValues() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST", new CustomItemStack(Material.DIAMOND, "&cTest"));
DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.5, max);
item.addItemSetting(setting);
item.register(plugin);
Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(null));
Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(-0.1));
Assertions.assertThrows(IllegalArgumentException.class, () -> setting.update(1.1));
}
Aggregations