forked from ftsrg-retelab/base
-
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 pull request #4 from szfp98/nandi
Nandi
- Loading branch information
Showing
4 changed files
with
58 additions
and
1 deletion.
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
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
38 changes: 37 additions & 1 deletion
38
train-sensor/src/test/java/hu/bme/mit/train/sensor/TrainSensorTest.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 |
---|---|---|
@@ -1,11 +1,47 @@ | ||
package hu.bme.mit.train.sensor; | ||
|
||
import TrainController; | ||
import TrainSensorImpl; | ||
import TrainUser; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import static org.mockito.Mockito.*; | ||
|
||
public class TrainSensorTest { | ||
|
||
|
||
TrainController mockTC; | ||
TrainUser mockTU; | ||
TrainsSensorImpl trainSensor; | ||
|
||
@Before | ||
public void before() { | ||
mockTC = mock(TrainController.class); | ||
mockTU = mock(TrainUser.class); | ||
trainSensor = new TrainSensorImpl(mockTC, mockTU); | ||
} | ||
|
||
@Test | ||
public void setAlarmState_TrainUser_Min() { | ||
trainSensor.overrideSpeedLimit(-1); | ||
verify(mockTU, times(1)).setAlarmState(true); | ||
} | ||
|
||
@Test | ||
public void setAlarmState_TrainUser_Max() { | ||
trainSensor.overrideSpeedLimit(501); | ||
verify(mockTU, times(1)).setAlarmState(true); | ||
} | ||
|
||
@Test | ||
public void setAlarmState_TrainUser_RelativeLimit() { | ||
trainSensor.overrideSpeedLimit(3); | ||
verify(mockTU, times(1)).setAlarmState(true); | ||
} | ||
|
||
@Test | ||
public void setAlarmState_TrainUser_Between() { | ||
trainSensor.overrideSpeedLimit(300); | ||
verify(mockTU, times(0)).setAlarmState(false); | ||
} | ||
} |
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