Skip to content

Commit

Permalink
feat: interface gametest
Browse files Browse the repository at this point in the history
  • Loading branch information
starforcraft committed Sep 10, 2024
1 parent f2eb987 commit c082b1a
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.refinedmods.refinedstorage.common.iface;

import com.refinedmods.refinedstorage.api.core.Action;
import com.refinedmods.refinedstorage.api.resource.ResourceAmount;
import com.refinedmods.refinedstorage.common.Platform;
import com.refinedmods.refinedstorage.common.util.IdentifierUtil;
Expand All @@ -13,6 +14,7 @@
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;

import static com.refinedmods.refinedstorage.common.GameTestUtil.asResource;
import static com.refinedmods.refinedstorage.common.GameTestUtil.assertInterfaceEmpty;
import static com.refinedmods.refinedstorage.common.GameTestUtil.getItemAsDamaged;
import static com.refinedmods.refinedstorage.common.GameTestUtil.insert;
import static com.refinedmods.refinedstorage.common.GameTestUtil.interfaceContainsExactly;
Expand Down Expand Up @@ -177,4 +179,66 @@ public static void shouldExportFluid(final GameTestHelper helper) {
.thenSucceed();
});
}

@GameTest(template = "empty_15x15")
public static void shouldImportItem(final GameTestHelper helper) {
preparePlot(helper, (iface, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 5);
insert(helper, network, STONE, 15);
}));

// Assert
sequence
.thenWaitUntil(assertInterfaceEmpty(helper, pos))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(DIRT), 5),
new ResourceAmount(asResource(STONE), 15)
))
.thenExecute(() -> iface.getExportedResources().insert(asResource(DIRT), 5, Action.EXECUTE))
.thenWaitUntil(assertInterfaceEmpty(helper, pos))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(DIRT), 10),
new ResourceAmount(asResource(STONE), 15)
))
.thenSucceed();
});
}

@GameTest(template = "empty_15x15")
public static void shouldImportFluid(final GameTestHelper helper) {
preparePlot(helper, (iface, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 5);
insert(helper, network, STONE, 15);
}));

// Assert
sequence
.thenWaitUntil(assertInterfaceEmpty(helper, pos))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 5),
new ResourceAmount(asResource(STONE), 15)
))
.thenExecute(() -> iface.getExportedResources().insert(
asResource(WATER), Platform.INSTANCE.getBucketAmount() * 5, Action.EXECUTE
))
.thenWaitUntil(assertInterfaceEmpty(helper, pos))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 10),
new ResourceAmount(asResource(STONE), 15)
))
.thenSucceed();
});
}
}

0 comments on commit c082b1a

Please sign in to comment.