45 lines
749 B
Java
45 lines
749 B
Java
package domain;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
|
class R2D2Test {
|
|
|
|
R2D2 Herbert;
|
|
int id = 0;
|
|
String name = "Herbert";
|
|
@BeforeEach
|
|
void setup(){
|
|
Herbert = new R2D2(id, name);
|
|
}
|
|
|
|
|
|
//Tests for basic functions
|
|
@Test
|
|
void getId() {
|
|
assertEquals(0, Herbert.getId());
|
|
}
|
|
|
|
@Test
|
|
void getName() {
|
|
assertEquals(name, Herbert.getName());
|
|
}
|
|
|
|
@Test
|
|
void triggerPowerSwitch() {
|
|
Herbert.triggerPowerSwitch();
|
|
assertTrue(Herbert.isPowerOn());
|
|
}
|
|
|
|
@Test
|
|
void isPowerOn() {
|
|
assertFalse(Herbert.isPowerOn());
|
|
Herbert.triggerPowerSwitch();
|
|
assertTrue(Herbert.isPowerOn());
|
|
}
|
|
|
|
|
|
} |