Skip to content

Commit

Permalink
@saleem: new broken test: adding method popNextPressurePsiValue() to …
Browse files Browse the repository at this point in the history
…interface ISensor using TDD. This commit at the 'Red' stage of 'RGR'
  • Loading branch information
saleem committed Oct 18, 2013
1 parent c362e81 commit 9269117
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
@@ -1,4 +1,5 @@
package tddmicroexercises.tirepressuremonitoringsystem;

public interface ISensor {
double popNextPressurePsiValue();
}
Expand Up @@ -4,7 +4,8 @@
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.is;
import static java.lang.Boolean.FALSE;
import static org.mockito.Mockito.mock;
import static java.lang.Boolean.TRUE;
import static org.mockito.Mockito.*;

public class AlarmTest {
@Test
Expand All @@ -16,4 +17,14 @@ public void canCreatAlarmWithGivenSensor() {
public void aNewAlarmIsOff() {
assertThat((new Alarm()).isAlarmOn(), is(FALSE));
}

@Test
public void alarmIsOnWhenSensorValueBelowThreshold() {
ISensor sensor = mock(ISensor.class);
when(sensor.popNextPressurePsiValue()).thenReturn(0D);
Alarm alarm = new Alarm(sensor);
alarm.check();
assertThat(alarm.isAlarmOn(), is(TRUE));
}

}

0 comments on commit 9269117

Please sign in to comment.