updated tests and split some tests

This commit is contained in:
Lucas Pleß 2012-03-06 17:11:21 +01:00
parent 4dc7623153
commit 43543682f9
3 changed files with 107 additions and 7 deletions

View File

@ -53,7 +53,40 @@ public class BuntiDMXDeviceTest {
options.put("red", 123); options.put("red", 123);
assertTrue(dut.setValuesFromOptions(options)); assertTrue(dut.setValuesFromOptions(options));
} }
@Test
public void testSetValuesFromOptionsWrong() throws Exception {
Map<String, Object> options = new HashMap<String, Object>();
options.put("reddddwrong", 123);
assertTrue(dut.setValuesFromOptions(options));
}
@Test
public void testSetValuesFromOptionsWrong2() throws Exception {
Map<String, Object> options = new HashMap<String, Object>();
options.put("red", null);
assertFalse(dut.setValuesFromOptions(options));
}
@Test
public void testSetChannelValueWrong() throws Exception {
assertFalse(dut.setChannelValueByName("nonexistend", 42));
}
@Test
public void testSetChannelValue() throws Exception {
assertTrue(dut.setChannelValueByName("red", 42));
}
@Test
public void testGetChannelValueOkay() throws Exception {
assertEquals(dut.getChannelValueByName("red"), 0);
}
@Test
public void testGetChannelValueWrong() throws Exception {
assertEquals(dut.getChannelValueByName("nonexistent"),0 );
}
@Test @Test
public void testGetChannelData() throws Exception { public void testGetChannelData() throws Exception {
@ -82,4 +115,5 @@ public class BuntiDMXDeviceTest {
Map<Integer,Integer> channelData = dut.getChannelData(); Map<Integer,Integer> channelData = dut.getChannelData();
assertEquals(6, channelData.size()); assertEquals(6, channelData.size());
} }
} }

View File

@ -1,6 +1,5 @@
package de.ctdo.bunti.model; package de.ctdo.bunti.model;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -59,4 +58,12 @@ public class Par56SpotTest {
assertEquals(255,dut.getColorGreen()); assertEquals(255,dut.getColorGreen());
assertEquals(255,dut.getColorBlue()); assertEquals(255,dut.getColorBlue());
} }
@Test
public void testToString() throws Exception {
dut.setColorRed(123);
dut.setColorGreen(111);
dut.setColorBlue(42);
assertEquals("Par56Spot 23, device [123,111,42]", dut.toString());
}
} }

View File

@ -4,6 +4,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class Strobe1500Test { public class Strobe1500Test {
Strobe1500 dut; Strobe1500 dut;
@ -15,48 +16,106 @@ public class Strobe1500Test {
} }
@Test @Test
public void testSpeed() throws Exception { public void testSetSpeed1() throws Exception {
assertTrue(dut.setSpeed(0));
}
@Test
public void testSetSpeed2() throws Exception {
assertTrue(dut.setSpeed(128));
}
@Test
public void testSetSpeed3() throws Exception {
assertTrue(dut.setSpeed(255));
}
@Test
public void testGetSpeed1() throws Exception {
dut.setSpeed(0); dut.setSpeed(0);
assertEquals(0,dut.getSpeed()); assertEquals(0,dut.getSpeed());
}
@Test
public void testGetSpeed2() throws Exception {
dut.setSpeed(128); dut.setSpeed(128);
assertEquals(128,dut.getSpeed()); assertEquals(128,dut.getSpeed());
}
@Test
public void testGetSpeed3() throws Exception {
dut.setSpeed(255); dut.setSpeed(255);
assertEquals(255,dut.getSpeed()); assertEquals(255,dut.getSpeed());
} }
@Test @Test
public void testIntensity() throws Exception { public void testIntensity1() throws Exception {
dut.setIntensity(0); dut.setIntensity(0);
assertEquals(0,dut.getIntensity()); assertEquals(0,dut.getIntensity());
}
@Test
public void testIntensity2() throws Exception {
dut.setIntensity(128); dut.setIntensity(128);
assertEquals(128,dut.getIntensity()); assertEquals(128,dut.getIntensity());
}
@Test
public void testIntensity3() throws Exception {
dut.setIntensity(255); dut.setIntensity(255);
assertEquals(255,dut.getIntensity()); assertEquals(255,dut.getIntensity());
} }
@Test @Test
public void testMode() throws Exception { public void testMode1() throws Exception {
dut.setMode(0); dut.setMode(0);
assertEquals(0,dut.getMode()); assertEquals(0,dut.getMode());
}
@Test
public void testMode2() throws Exception {
dut.setMode(128); dut.setMode(128);
assertEquals(128,dut.getMode()); assertEquals(128,dut.getMode());
}
@Test
public void testMode3() throws Exception {
dut.setMode(255); dut.setMode(255);
assertEquals(255,dut.getMode()); assertEquals(255,dut.getMode());
} }
@Test @Test
public void testSwitchOff() throws Exception { public void testSwitchOffSpeed() throws Exception {
dut.switchOff(); dut.switchOff();
assertEquals(0,dut.getSpeed()); assertEquals(0,dut.getSpeed());
}
@Test
public void testSwitchOffIntensity() throws Exception {
dut.switchOff();
assertEquals(0,dut.getIntensity()); assertEquals(0,dut.getIntensity());
}
@Test
public void testSwitchOffMode() throws Exception {
dut.switchOff();
assertEquals(0,dut.getMode()); assertEquals(0,dut.getMode());
} }
@Test @Test
public void testSwitchOn() throws Exception { public void testSwitchOnSpeed() throws Exception {
dut.switchOn(); dut.switchOn();
assertEquals(255,dut.getSpeed()); assertEquals(255,dut.getSpeed());
}
@Test
public void testSwitchOnIntensity() throws Exception {
dut.switchOn();
assertEquals(255,dut.getIntensity()); assertEquals(255,dut.getIntensity());
}
@Test
public void testSwitchOnMode() throws Exception {
dut.switchOn();
assertEquals(0,dut.getMode()); assertEquals(0,dut.getMode());
} }
@Test
public void testToString() throws Exception {
dut.setSpeed(123);
dut.setIntensity(111);
dut.setMode(42);
assertEquals("Strobe1500 23, device [123,111,42]", dut.toString());
}
} }