Search in sources :

Example 1 with DoubleRangeSetting

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));
}
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 DoubleRangeSetting

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

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

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