diff --git a/domain/R2D2.java b/domain/R2D2.java index 410667c..322f217 100644 --- a/domain/R2D2.java +++ b/domain/R2D2.java @@ -5,30 +5,48 @@ public class R2D2 implements Robot{ private String name; private boolean power; + /** + * Constructor + * @param id> int + * @param name> String + */ public R2D2(int id, String name){ this.id = id; this.name = name; power = false; } + + /** + * @see domain.RobotControl + */ @Override public int getId() { return id; } + /** + * @see domain.RobotControl + */ @Override public String getName() { return name; } + /** + * @see domain.RobotControl + */ @Override public void triggerPowerSwitch() { - if(power = false){ + if(power == false){ power = true; }else{ power = false; } } + /** + * @see domain.RobotControl + */ @Override public boolean isPowerOn() { return power; diff --git a/domain/R2D2Test.java b/domain/R2D2Test.java new file mode 100644 index 0000000..d544f21 --- /dev/null +++ b/domain/R2D2Test.java @@ -0,0 +1,45 @@ +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()); + } + + +} \ No newline at end of file