added more tests

This commit is contained in:
Lucas Pleß 2012-03-07 22:10:22 +01:00
parent dd4f730ca7
commit a93247984c
4 changed files with 235 additions and 0 deletions

View File

@ -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<String,Object> options = new HashMap<String, Object>();
// options.put("optionA", "valueA");
// options.put("optionB", 42);
// assertTrue(dut.setDevice(12, options));
// }
}

View File

@ -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());
}
}

View File

@ -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<DMXChannel> channels = dut.getAllChannels();
assertEquals(1, channels.size());
}
}

View File

@ -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 {
}
}