Skip to content

Commit

Permalink
feat: storage blocks gametest
Browse files Browse the repository at this point in the history
  • Loading branch information
starforcraft committed Dec 15, 2024
1 parent 365f3c6 commit 1897680
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.refinedmods.refinedstorage.api.resource.ResourceAmount;
import com.refinedmods.refinedstorage.api.resource.filter.FilterMode;
import com.refinedmods.refinedstorage.api.storage.AccessMode;
import com.refinedmods.refinedstorage.common.Platform;
import com.refinedmods.refinedstorage.common.util.IdentifierUtil;

Expand Down Expand Up @@ -242,4 +243,78 @@ public static void shouldVoidFluids(final GameTestHelper helper) {
.thenSucceed();
});
}

@GameTest(template = "empty_15x15")
public static void shouldRespectFluidInsertAccessMode(final GameTestHelper helper) {
preparePlot(helper, false, (storageBlock, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network ->
insert(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 16)));

// Act
storageBlock.setAccessMode(AccessMode.INSERT);

// Assert
sequence
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 16)
))
.thenExecute(networkIsAvailable(helper, pos, network -> {
insert(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 16);
insert(helper, network, LAVA, Platform.INSTANCE.getBucketAmount());
}))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 32),
new ResourceAmount(asResource(LAVA), Platform.INSTANCE.getBucketAmount())
))
.thenExecute(networkIsAvailable(helper, pos, network ->
extract(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 16, false)))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 32),
new ResourceAmount(asResource(LAVA), Platform.INSTANCE.getBucketAmount())
))
.thenSucceed();
});
}

@GameTest(template = "empty_15x15")
public static void shouldRespectFluidExtractAccessMode(final GameTestHelper helper) {
preparePlot(helper, false, (storageBlock, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network ->
insert(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 16)));

// Assert
sequence
.thenExecute(() -> storageBlock.setAccessMode(AccessMode.EXTRACT))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 16)
))
.thenExecute(networkIsAvailable(helper, pos, network -> {
insert(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 16, false);
insert(helper, network, LAVA, Platform.INSTANCE.getBucketAmount(), false);
}))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 16)
))
.thenExecute(networkIsAvailable(helper, pos, network ->
extract(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 8)))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 8)
))
.thenSucceed();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public static void shouldVoidItems(final GameTestHelper helper) {
}

@GameTest(template = "empty_15x15")
public static void shouldRespectInsertAccessMode(final GameTestHelper helper) {
public static void shouldRespectItemInsertAccessMode(final GameTestHelper helper) {
preparePlot(helper, true, (storageBlock, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> insert(helper, network, STONE, 64)));
Expand Down Expand Up @@ -339,7 +339,7 @@ public static void shouldRespectInsertAccessMode(final GameTestHelper helper) {
}

@GameTest(template = "empty_15x15")
public static void shouldRespectExtractAccessMode(final GameTestHelper helper) {
public static void shouldRespectItemExtractAccessMode(final GameTestHelper helper) {
preparePlot(helper, true, (storageBlock, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> insert(helper, network, STONE, 64)));
Expand Down

0 comments on commit 1897680

Please sign in to comment.