-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: portable grid item
- Loading branch information
Showing
34 changed files
with
951 additions
and
212 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...a/com/refinedmods/refinedstorage2/api/network/impl/energy/AbstractProxyEnergyStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.refinedmods.refinedstorage2.api.network.impl.energy; | ||
|
||
import com.refinedmods.refinedstorage2.api.core.Action; | ||
import com.refinedmods.refinedstorage2.api.network.energy.EnergyStorage; | ||
|
||
public abstract class AbstractProxyEnergyStorage implements EnergyStorage { | ||
private final EnergyStorage energyStorage; | ||
|
||
public AbstractProxyEnergyStorage(final EnergyStorage energyStorage) { | ||
this.energyStorage = energyStorage; | ||
} | ||
|
||
@Override | ||
public long getStored() { | ||
return energyStorage.getStored(); | ||
} | ||
|
||
@Override | ||
public long getCapacity() { | ||
return energyStorage.getCapacity(); | ||
} | ||
|
||
@Override | ||
public long receive(final long amount, final Action action) { | ||
return energyStorage.receive(amount, action); | ||
} | ||
|
||
@Override | ||
public long extract(final long amount, final Action action) { | ||
return energyStorage.extract(amount, action); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../java/com/refinedmods/refinedstorage2/api/network/impl/energy/ProxyEnergyStorageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.refinedmods.refinedstorage2.api.network.impl.energy; | ||
|
||
import com.refinedmods.refinedstorage2.api.core.Action; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class ProxyEnergyStorageTest { | ||
AbstractProxyEnergyStorage sut; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
sut = new AbstractProxyEnergyStorage(new EnergyStorageImpl(100)) { | ||
}; | ||
} | ||
|
||
@Test | ||
void testProxy() { | ||
// Act | ||
final long capacity = sut.getCapacity(); | ||
final long received = sut.receive(100, Action.EXECUTE); | ||
final long extracted = sut.extract(15, Action.EXECUTE); | ||
final long stored = sut.getStored(); | ||
|
||
// Assert | ||
assertThat(capacity).isEqualTo(100); | ||
assertThat(received).isEqualTo(100); | ||
assertThat(extracted).isEqualTo(15); | ||
assertThat(stored).isEqualTo(100 - 15); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.