mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Added tests for the RaceTimerController #test #story[16]
This commit is contained in:
@@ -23,7 +23,7 @@ public class RaceTimerController implements Initializable{
|
|||||||
* @param time the time in seconds
|
* @param time the time in seconds
|
||||||
* @return a formatted string
|
* @return a formatted string
|
||||||
*/
|
*/
|
||||||
private String convertTimeToMinutesSeconds(int time){
|
public String convertTimeToMinutesSeconds(int time){
|
||||||
if (time < 0){
|
if (time < 0){
|
||||||
return String.format("-%02d:%02d", (time * -1) / 60, (time * -1)% 60);
|
return String.format("-%02d:%02d", (time * -1) / 60, (time * -1)% 60);
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ public class RaceTimerController implements Initializable{
|
|||||||
* Controller to control the race timer
|
* Controller to control the race timer
|
||||||
* @param race the race the timer is timing
|
* @param race the race the timer is timing
|
||||||
*/
|
*/
|
||||||
RaceTimerController(Race race){
|
public RaceTimerController(Race race){
|
||||||
this.race = race;
|
this.race = race;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package seng302;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import seng302.controllers.RaceTimerController;
|
||||||
|
import seng302.models.Race;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
|
public class TestRaceTimer {
|
||||||
|
@Test
|
||||||
|
public void testPositiveTimeString(){
|
||||||
|
RaceTimerController controller = new RaceTimerController(new Race());
|
||||||
|
String result = controller.convertTimeToMinutesSeconds(61);
|
||||||
|
|
||||||
|
assertTrue(result.equals("01:01"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNegativeTimeString(){
|
||||||
|
RaceTimerController controller = new RaceTimerController(new Race());
|
||||||
|
String result = controller.convertTimeToMinutesSeconds(-61);
|
||||||
|
|
||||||
|
assertTrue(result.equals("-01:01"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user