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 11, 2024
1 parent e3797ed commit c91a3be
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ void setFuzzyMode(final boolean fuzzyMode) {
filter.setFuzzyMode(fuzzyMode);
}

void setFilters(final List<ResourceAmount> filters) {
void clearFilters() {
filter.getFilterContainer().clear();
}

void setFilters(final List<ResourceAmount> filters) {
for (int i = 0; i < filters.size(); i++) {
filter.getFilterContainer().set(i, filters.get(i));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,29 @@ public static void shouldExportItem(final GameTestHelper helper) {
// Act
iface.setFuzzyMode(false);
iface.setFilters(List.of(
new ResourceAmount(asResource(DIRT), 5),
new ResourceAmount(asResource(DIRT), 10),
new ResourceAmount(asResource(DIAMOND_CHESTPLATE), 1)
));

// Assert
sequence
.thenWaitUntil(interfaceContainsExactly(
helper,
pos,
new ResourceAmount(asResource(DIRT), 10)
))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(STONE), 15),
new ResourceAmount(asResource(damagedDiamondChestplate), 1)
))
.thenExecute(() -> {
iface.clearFilters();
iface.setFilters(List.of(
new ResourceAmount(asResource(DIRT), 5)
));
})
.thenWaitUntil(interfaceContainsExactly(
helper,
pos,
Expand All @@ -66,16 +83,17 @@ public static void shouldExportItem(final GameTestHelper helper) {
new ResourceAmount(asResource(damagedDiamondChestplate), 1)
))
.thenExecute(() -> iface.setFilters(List.of(
new ResourceAmount(asResource(DIRT), 10))
))
new ResourceAmount(asResource(DIRT), 7)
)))
.thenWaitUntil(interfaceContainsExactly(
helper,
pos,
new ResourceAmount(asResource(DIRT), 10)
new ResourceAmount(asResource(DIRT), 7)
))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(DIRT), 3),
new ResourceAmount(asResource(STONE), 15),
new ResourceAmount(asResource(damagedDiamondChestplate), 1)
))
Expand Down Expand Up @@ -119,9 +137,12 @@ public static void shouldExportItemFuzzy(final GameTestHelper helper) {
new ResourceAmount(asResource(DIRT), 5),
new ResourceAmount(asResource(STONE), 15)
))
.thenExecute(() -> iface.setFilters(List.of(
new ResourceAmount(asResource(DIRT), 10))
))
.thenExecute(() -> {
iface.clearFilters();
iface.setFilters(List.of(
new ResourceAmount(asResource(DIRT), 10))
);
})
.thenWaitUntil(interfaceContainsExactly(
helper,
pos,
Expand All @@ -148,10 +169,23 @@ public static void shouldExportFluid(final GameTestHelper helper) {
}));

// Act
iface.setFilters(List.of(new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 5)));
iface.setFilters(List.of(new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 10)));

// Assert
sequence
.thenWaitUntil(interfaceContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 10)
))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(STONE), 15)
))
.thenExecute(() -> iface.setFilters(List.of(
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 5))
))
.thenWaitUntil(interfaceContainsExactly(
helper,
pos,
Expand All @@ -164,16 +198,17 @@ public static void shouldExportFluid(final GameTestHelper helper) {
new ResourceAmount(asResource(STONE), 15)
))
.thenExecute(() -> iface.setFilters(List.of(
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 10))
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 7))
))
.thenWaitUntil(interfaceContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 10)
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 7)
))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount() * 3),
new ResourceAmount(asResource(STONE), 15)
))
.thenSucceed();
Expand Down

0 comments on commit c91a3be

Please sign in to comment.