-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into manual_testing
- Loading branch information
Showing
22 changed files
with
1,807 additions
and
332 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -117,5 +117,4 @@ | |
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
class CisternsTest { | ||
private Cisterns cisterns; | ||
private PipeSystem pipeSystem; | ||
private Game game; | ||
|
||
@BeforeEach | ||
public void init() { | ||
cisterns = new Cisterns(); | ||
pipeSystem = mock(PipeSystem.class); | ||
game = mock(Game.class); | ||
} | ||
|
||
@Test | ||
void PickUpPump() { | ||
cisterns.CreatePump(); | ||
cisterns.PickUpPump(); | ||
assertEquals(0, cisterns.getAvailablePumps()); | ||
} | ||
|
||
@Test | ||
void CreatePumpCreatesNewPump() { | ||
cisterns.CreatePump(); | ||
assertEquals(1, cisterns.getAvailablePumps()); | ||
} | ||
|
||
@Test | ||
void CreatePipeCreatesNewPipe() { | ||
cisterns.CreatePipe(); | ||
assertEquals(1, cisterns.neighbours.size()); | ||
} | ||
|
||
@Test | ||
void CreatePipeCreatesNewPipeWithNeighbour() { | ||
cisterns.CreatePipe(); | ||
assertEquals(cisterns, cisterns.neighbours.get(0).neighbours.get(0)); | ||
} | ||
|
||
@Test | ||
void CantPickUpPumpIfNoPumpsAvailable() { | ||
cisterns.PickUpPump(); | ||
assertEquals(0, cisterns.getAvailablePumps()); | ||
} | ||
|
||
@Test | ||
void CisternsAddsWaterForMechnaics() { | ||
cisterns.AddMWater(5); | ||
verify(pipeSystem,times(1)).incMWater(5); | ||
} | ||
|
||
@Test | ||
void AfterRandomTimeAPipeIsCreated() { | ||
int size = cisterns.neighbours.size(); | ||
cisterns.TimerNotify(); | ||
if(size == cisterns.neighbours.size()) { | ||
AfterRandomTimeAPipeIsCreated(); | ||
} | ||
assertEquals(1, cisterns.neighbours.size()); | ||
} | ||
|
||
@Test | ||
void AfterRandomTimeAPumpIsCreated() { | ||
int size = cisterns.getAvailablePumps(); | ||
cisterns.TimerNotify(); | ||
if(size == cisterns.getAvailablePumps()) { | ||
AfterRandomTimeAPumpIsCreated(); | ||
} | ||
assertEquals(1, cisterns.getAvailablePumps()); | ||
} | ||
|
||
@Test | ||
void WaterAddedToCisterns() { | ||
Pipe pipe = mock(Pipe.class); | ||
when(pipe.GetStorage()).thenReturn(10); | ||
cisterns.Path(pipe); | ||
verify(pipe,times(1)).SetStorage(0); | ||
} | ||
} |
Oops, something went wrong.