Search in sources :

Example 6 with BlockMeterClient

use of win.baruna.blockmeter.BlockMeterClient in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method testSetColorIndex.

@ParameterizedTest
@JSONSource(classes = { ParseDyeColor.class }, jsons = { "red", "blue", "white", "black" })
void testSetColorIndex(DyeColor color) {
    try (MockedStatic<BlockMeterClient> client = getBMC()) {
        ClientMeasureBox.setColorIndex(color.getId());
        final ClientMeasureBox box = ClientMeasureBox.getBox(new BlockPos(0, 0, 0), OVERWORLD_ID);
        assertThat(box.getColor()).isEqualTo(color);
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockPos(net.minecraft.util.math.BlockPos) ParseBlockPos(de.modprog.blockmeter.util.parser.ParseBlockPos) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with BlockMeterClient

use of win.baruna.blockmeter.BlockMeterClient in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method getBMC.

@SuppressWarnings("unchecked")
private MockedStatic<BlockMeterClient> getBMC() {
    final MockedStatic<BlockMeterClient> client = Mockito.mockStatic(BlockMeterClient.class);
    final ConfigManager<ModConfig> configHolder = Mockito.mock(ConfigManager.class);
    when(configHolder.getConfig()).thenReturn(new ModConfig());
    client.when(BlockMeterClient::getConfigManager).thenReturn(configHolder);
    return client;
}
Also used : BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) ModConfig(win.baruna.blockmeter.ModConfig)

Example 8 with BlockMeterClient

use of win.baruna.blockmeter.BlockMeterClient in project BlockMeter by ModProg.

the class ClientMeasureBoxTest method testGetMeasureBox.

@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseIdentifier.class, ParseDyeColor.class, Boolean.class }, jsons = { "(1|2|3), overworld, blue, true", "(-10|200|3123), nether, black, false", "(-112312|100|33), end, red, true" })
void testGetMeasureBox(final BlockPos bp, final Identifier id, final DyeColor color, final boolean incrementColor) {
    try (MockedStatic<BlockMeterClient> client = getBMC()) {
        final ModConfig config = BlockMeterClient.getConfigManager().getConfig();
        config.colorIndex = color.getId();
        config.incrementColor = incrementColor;
        final ClientMeasureBox box = ClientMeasureBox.getBox(bp, id);
        assertThat(box.getBlockStart()).isEqualTo(bp);
        assertThat(box.getBlockEnd()).isEqualTo(bp);
        assertThat(box.getDimension()).isEqualTo(id);
        assertThat(box.isFinished()).isFalse();
        assertThat(box.getColor()).isEqualTo(color);
        if (!incrementColor)
            assertThat(DyeColor.byId(config.colorIndex)).isEqualTo(color);
        else
            assertThat(DyeColor.byId(config.colorIndex)).isNotEqualTo(color);
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) ModConfig(win.baruna.blockmeter.ModConfig) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BlockMeterClient (win.baruna.blockmeter.BlockMeterClient)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 ClientMeasureBox (win.baruna.blockmeter.measurebox.ClientMeasureBox)7 JSONSource (de.modprog.blockmeter.util.JSONSource)6 ParseBlockPos (de.modprog.blockmeter.util.parser.ParseBlockPos)3 BlockPos (net.minecraft.util.math.BlockPos)3 ModConfig (win.baruna.blockmeter.ModConfig)2 Test (org.junit.jupiter.api.Test)1