Skip to content

Commit

Permalink
+ laser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcigo36 committed Apr 21, 2017
1 parent c7aea5c commit 56da240
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/hu/bme/mit/spaceship/GT4500.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public boolean fireLasers(FiringMode firingMode) {
if(firingMode == FiringMode.SINGLE)
{
//no lasers
firingSuccess = false;
firingSuccess = true;
}
else if(firingMode == FiringMode.ALL)
{
//no lasrs
firingSuccess = false;
firingSuccess = true;
}


Expand Down
29 changes: 29 additions & 0 deletions src/test/java/hu/bme/mit/spaceship/GT4500Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,33 @@ public void fireTorpedos_All_Success(){
assertEquals(true, result);
}

public void fireLasers_Single_Success(){
// Arrange

when(mts.fire(1)).thenReturn(true);
when(mts.isEmpty()).thenReturn(false);
when(mts.getNumberOfTorpedos()).thenReturn(1);


// Assert
assertEquals(true, ship.fireLasers(FiringMode.SINGLE));
}

@Test
public void fireLasers_All_Success(){
// Arrange
when(mts.fire(1)).thenReturn(true);
when(mts.isEmpty()).thenReturn(false);
when(mts.getNumberOfTorpedos()).thenReturn(1);
when(mts2.fire(1)).thenReturn(true);
when(mts2.isEmpty()).thenReturn(false);
when(mts2.getNumberOfTorpedos()).thenReturn(1);

// Act
boolean result = ship.fireLasers(FiringMode.ALL);

// Assert
assertEquals(true, result);
}

}

0 comments on commit 56da240

Please sign in to comment.