Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Interface and Sensor Test cases #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package hu.bme.mit.train.interfaces;

public interface TrainUser {

int getJoystickPosition();

boolean getAlarmFlag();

boolean getAlarmState();
void setAlarmState(boolean alarmState);
void overrideJoystickPosition(int joystickPosition);

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,54 @@
package hu.bme.mit.train.sensor;

import hu.bme.mit.train.user.TrainUserImpl;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import hu.bme.mit.train.interfaces.TrainController;
import hu.bme.mit.train.interfaces.TrainSensor;
import hu.bme.mit.train.interfaces.TrainUser;


import static org.mockito.Mockito.*;

public class TrainSensorTest {

TrainSensorImpl sensor;
TrainController controller;
TrainUser user;
@Before
public void before() {
// TODO Add initializations


controller = mock(TrainController.class);
user = new TrainUserImpl(controller);
sensor = new TrainSensorImpl(controller,user);
}
@Test
public void HighSpeedLimit() {
//initial speed limit

sensor.overrideSpeedLimit(2000);
System.out.println(user.getAlarmState());
Assert.assertEquals(true,user.getAlarmState());
}
@Test
public void LowSpeedLimit(){
sensor.overrideSpeedLimit(-30);
System.out.println(user.getAlarmState());
Assert.assertTrue(user.getAlarmState());
}
@Test
public void AlarmWorkingSet(){
user.setAlarmState(true);
Assert.assertTrue(user.getAlarmState());
user.setAlarmState(false);
Assert.assertFalse(user.getAlarmState());
}
@Test
public void ThisIsAnExampleTestStub() {
// TODO Delete this and add test cases based on the issues
public void TooMuchSpeed()
{
sensor.overrideSpeedLimit(1);
Assert.assertTrue(user.getAlarmState());
}
}