From 18976803a888392c3c6f32976d5eed70c46a0f46 Mon Sep 17 00:00:00 2001 From: Starforcraft Date: Sun, 15 Dec 2024 12:52:46 +0100 Subject: [PATCH] feat: storage blocks gametest --- .../storageblock/StorageBlockFluidTest.java | 75 +++++++++++++++++++ .../storageblock/StorageBlockItemTest.java | 4 +- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockFluidTest.java b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockFluidTest.java index 112ef5c72..b36da2066 100644 --- a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockFluidTest.java +++ b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockFluidTest.java @@ -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; @@ -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(); + }); + } } diff --git a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockItemTest.java b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockItemTest.java index bc9e4c2bd..611396f98 100644 --- a/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockItemTest.java +++ b/refinedstorage-neoforge/src/test/java/com/refinedmods/refinedstorage/common/storage/storageblock/StorageBlockItemTest.java @@ -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))); @@ -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)));