From 43543682f91fa8fcce9a3c58d213f9bd1ba21274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Tue, 6 Mar 2012 17:11:21 +0100 Subject: [PATCH] updated tests and split some tests --- .../ctdo/bunti/model/BuntiDMXDeviceTest.java | 36 +++++++++- .../de/ctdo/bunti/model/Par56SpotTest.java | 9 ++- .../de/ctdo/bunti/model/Strobe1500Test.java | 69 +++++++++++++++++-- 3 files changed, 107 insertions(+), 7 deletions(-) diff --git a/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java b/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java index 1466d43..245789a 100644 --- a/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java +++ b/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java @@ -53,7 +53,40 @@ public class BuntiDMXDeviceTest { options.put("red", 123); assertTrue(dut.setValuesFromOptions(options)); } - + + @Test + public void testSetValuesFromOptionsWrong() throws Exception { + Map options = new HashMap(); + options.put("reddddwrong", 123); + assertTrue(dut.setValuesFromOptions(options)); + } + + @Test + public void testSetValuesFromOptionsWrong2() throws Exception { + Map options = new HashMap(); + 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 public void testGetChannelData() throws Exception { @@ -82,4 +115,5 @@ public class BuntiDMXDeviceTest { Map channelData = dut.getChannelData(); assertEquals(6, channelData.size()); } + } diff --git a/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java b/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java index d60f7c4..e29a087 100644 --- a/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java +++ b/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java @@ -1,6 +1,5 @@ package de.ctdo.bunti.model; -import org.junit.After; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; @@ -59,4 +58,12 @@ public class Par56SpotTest { assertEquals(255,dut.getColorGreen()); 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()); + } } diff --git a/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java b/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java index 809534a..08ad06a 100644 --- a/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java +++ b/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java @@ -4,6 +4,7 @@ import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class Strobe1500Test { Strobe1500 dut; @@ -15,48 +16,106 @@ public class Strobe1500Test { } @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); assertEquals(0,dut.getSpeed()); + } + @Test + public void testGetSpeed2() throws Exception { dut.setSpeed(128); assertEquals(128,dut.getSpeed()); + } + @Test + public void testGetSpeed3() throws Exception { dut.setSpeed(255); assertEquals(255,dut.getSpeed()); } @Test - public void testIntensity() throws Exception { + public void testIntensity1() throws Exception { dut.setIntensity(0); assertEquals(0,dut.getIntensity()); + } + @Test + public void testIntensity2() throws Exception { dut.setIntensity(128); assertEquals(128,dut.getIntensity()); + } + @Test + public void testIntensity3() throws Exception { dut.setIntensity(255); assertEquals(255,dut.getIntensity()); } @Test - public void testMode() throws Exception { + public void testMode1() throws Exception { dut.setMode(0); assertEquals(0,dut.getMode()); + } + @Test + public void testMode2() throws Exception { dut.setMode(128); assertEquals(128,dut.getMode()); + } + @Test + public void testMode3() throws Exception { dut.setMode(255); assertEquals(255,dut.getMode()); } @Test - public void testSwitchOff() throws Exception { + public void testSwitchOffSpeed() throws Exception { dut.switchOff(); assertEquals(0,dut.getSpeed()); + } + @Test + public void testSwitchOffIntensity() throws Exception { + dut.switchOff(); assertEquals(0,dut.getIntensity()); + } + @Test + public void testSwitchOffMode() throws Exception { + dut.switchOff(); assertEquals(0,dut.getMode()); } @Test - public void testSwitchOn() throws Exception { + public void testSwitchOnSpeed() throws Exception { dut.switchOn(); assertEquals(255,dut.getSpeed()); + } + + @Test + public void testSwitchOnIntensity() throws Exception { + dut.switchOn(); assertEquals(255,dut.getIntensity()); + } + + @Test + public void testSwitchOnMode() throws Exception { + dut.switchOn(); 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()); + } + }