package de.ctdo.bunti.model;

import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.*;

public class Par56SpotTest {
    Par56Spot dut;

    @Before
    public void setUp() throws Exception {
        dut = new Par56Spot(23,42,"device");
        
    }

    @Test
    public void testColorRed() throws Exception {
        dut.setColorRed(0);
        assertEquals(0,dut.getColorRed());
        dut.setColorRed(128);
        assertEquals(128,dut.getColorRed());
        dut.setColorRed(255);
        assertEquals(255,dut.getColorRed());
    }

    @Test
    public void testColorGreen() throws Exception {
        dut.setColorGreen(0);
        assertEquals(0,dut.getColorGreen());
        dut.setColorGreen(128);
        assertEquals(128,dut.getColorGreen());
        dut.setColorGreen(255);
        assertEquals(255,dut.getColorGreen());
    }

    @Test
    public void testColorBlue() throws Exception {
        dut.setColorBlue(0);
        assertEquals(0,dut.getColorBlue());
        dut.setColorBlue(128);
        assertEquals(128,dut.getColorBlue());
        dut.setColorBlue(255);
        assertEquals(255,dut.getColorBlue());
    }

    @Test
    public void testSwitchOff() throws Exception {
        dut.switchOff();
        assertEquals(0,dut.getColorRed());
        assertEquals(0,dut.getColorGreen());
        assertEquals(0,dut.getColorBlue());
    }

    @Test
    public void testSwitchOn() throws Exception {
        dut.switchOn();
        assertEquals(255,dut.getColorRed());
        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());
    }
}
