From a93247984c3b7d2d14338308cfd9b3dd7a474ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Wed, 7 Mar 2012 22:10:22 +0100 Subject: [PATCH] added more tests --- .../bunti/control/BuntiControllerTest.java | 23 +++++ .../de/ctdo/bunti/dmx/DMXChannelTest.java | 57 +++++++++++++ .../de/ctdo/bunti/dmx/DMXChannelsTest.java | 72 ++++++++++++++++ .../de/ctdo/bunti/dmx/DMXMixerImplTest.java | 83 +++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java create mode 100644 src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java create mode 100644 src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java create mode 100644 src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java diff --git a/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java b/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java new file mode 100644 index 0000000..92f752b --- /dev/null +++ b/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java @@ -0,0 +1,23 @@ +package de.ctdo.bunti.control; + +import org.junit.Before; + +public class BuntiControllerTest { + + BuntiControllerImpl dut; + + @Before + public void setUp() throws Exception { + dut = new BuntiControllerImpl(); +// dut.setDevicesDAO(daoMock); + } + +// @Test +// public void testSetDevice() throws Exception { +// Map options = new HashMap(); +// options.put("optionA", "valueA"); +// options.put("optionB", 42); +// assertTrue(dut.setDevice(12, options)); +// } + +} diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java new file mode 100644 index 0000000..df71b7f --- /dev/null +++ b/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java @@ -0,0 +1,57 @@ +package de.ctdo.bunti.dmx; + +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.*; + +/** + * @author: lucas + * @date: 07.03.12 21:47 + */ +public class DMXChannelTest { + DMXChannel dut; + + @Before + public void setUp() throws Exception { + dut = new DMXChannel(23, "testchannel"); + } + + @Test + public void testGetValue1() throws Exception { + assertEquals(0, dut.getValue()); + } + + @Test + public void testGetValue2() throws Exception { + dut.setValue(111); + assertEquals(111, dut.getValue()); + } + + @Test + public void testGetOffset() throws Exception { + assertEquals(23, dut.getOffset()); + } + + @Test + public void testSetOffset() throws Exception { + dut.setOffset(44); + assertEquals(44, dut.getOffset()); + } + + @Test + public void testGetName() throws Exception { + assertEquals("testchannel", dut.getName()); + } + + @Test + public void testSetName() throws Exception { + dut.setName("rapantel"); + assertEquals("rapantel", dut.getName()); + } + + @Test + public void testToString() throws Exception { + assertEquals("DMXChannel testchannel,23,0", dut.toString()); + } +} diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java new file mode 100644 index 0000000..cbc6922 --- /dev/null +++ b/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java @@ -0,0 +1,72 @@ +package de.ctdo.bunti.dmx; + +import org.junit.Before; +import org.junit.Test; + +import java.util.Collection; + +import static junit.framework.Assert.*; + +/** + * @author: lucas + * @date: 07.03.12 22:01 + */ +public class DMXChannelsTest { + DMXChannels dut; + + @Before + public void setUp() throws Exception { + dut = new DMXChannels(); + } + + @Test + public void testGetCount1() throws Exception { + assertEquals(0, dut.getCount()); + } + + @Test + public void testGetCount2() throws Exception { + dut.addChannel(new DMXChannel(1, "name")); + assertEquals(1, dut.getCount()); + } + + @Test + public void testGetChannelByName() throws Exception { + dut.addChannel(new DMXChannel(23, "name")); + assertNotNull(dut.getChannelByName("name")); + assertEquals(23, dut.getChannelByName("name").getOffset()); + } + + @Test + public void testAddChannel1() throws Exception { + assertTrue(dut.addChannel(new DMXChannel(42, "name"))); + } + + @Test + public void testAddChannel2() throws Exception { + assertTrue(dut.addChannel(new DMXChannel(42, "name"))); + assertFalse(dut.addChannel(new DMXChannel(42, "name"))); + } + + @Test + public void testAddChannel3() throws Exception { + assertFalse(dut.addChannel(new DMXChannel(42, null))); + } + + @Test + public void testAddChannel4() throws Exception { + assertFalse(dut.addChannel(null)); + } + + @Test + public void testGetAllChannels1() throws Exception { + assertEquals(0, dut.getAllChannels().size()); + } + + @Test + public void testGetAllChannels2() throws Exception { + dut.addChannel(new DMXChannel(23, "name")); + Collection channels = dut.getAllChannels(); + assertEquals(1, channels.size()); + } +} diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java new file mode 100644 index 0000000..3d4aeb7 --- /dev/null +++ b/src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java @@ -0,0 +1,83 @@ +package de.ctdo.bunti.dmx; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class DMXMixerImplTest { + DMXMixerImpl dut; + + @Before + public void setUp() throws Exception { + dut = new DMXMixerImpl(); + } + + @Test + public void testSetArtNetSender() throws Exception { + + } + + @Test + public void testSetArtNetDeviceAddress() throws Exception { + + } + + @Test + public void testInitDMXData() throws Exception { + + } + + @Test + public void testSendOutDMXBuffer() throws Exception { + + } + + @Test + public void testUpdateDevice() throws Exception { + + } + + @Test + public void testSetDMX512ChannelGood1() throws Exception { + assertTrue(dut.setDMX512Channel(512, 255)); + } + + @Test + public void testSetDMX512ChannelGood2() throws Exception { + assertTrue(dut.setDMX512Channel(512, 0)); + } + + @Test + public void testSetDMX512ChannelGood3() throws Exception { + assertTrue(dut.setDMX512Channel(1, -10)); + } + + @Test + public void testSetDMX512ChannelGood4() throws Exception { + assertTrue(dut.setDMX512Channel(140, 300)); + } + + @Test + public void testSetDMX512ChannelBad1() throws Exception { + assertFalse(dut.setDMX512Channel(0, 10)); + } + + @Test + public void testSetDMX512ChannelBad2() throws Exception { + assertFalse(dut.setDMX512Channel(513, 10)); + } + + @Test + public void testSetDMX512ChannelBad3() throws Exception { + assertFalse(dut.setDMX512Channel(-1, -10)); + } + + + + + @Test + public void testOnApplicationEvent() throws Exception { + + } +}