-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bd9461
commit 4c84e11
Showing
3 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package jlifx.bulb; | ||
|
||
import static org.easymock.EasyMock.expect; | ||
import static org.easymock.EasyMock.expectLastCall; | ||
import static org.junit.Assert.assertArrayEquals; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
import jlifx.packet.PacketService; | ||
|
||
public class BulbTest extends AbstractJLifxTestCase { | ||
|
||
@Test | ||
public void testBulbOperations() throws Exception { | ||
GatewayBulb gatewayBulb = getMockedGatewayBulb(); | ||
Bulb bulb = new Bulb(TEST_MAC_ADDRESS_1, gatewayBulb); | ||
|
||
assertArrayEquals(TEST_MAC_ADDRESS_1, bulb.getMacAddress()); | ||
assertEquals(gatewayBulb, bulb.getGatewayBulb()); | ||
assertTrue(bulb.equals(bulb)); | ||
} | ||
|
||
@Test | ||
public void testSwitchBulbOnOff() throws Exception { | ||
GatewayBulb gatewayBulb = getMockedGatewayBulb(); | ||
PacketService packetService = getMockedPacketService(); | ||
expect(gatewayBulb.getPacketService()).andReturn(packetService); | ||
expectLastCall().times(2); | ||
Bulb bulb = new Bulb(TEST_MAC_ADDRESS_1, gatewayBulb); | ||
packetService.sendPowerManagementPacket(bulb, true); | ||
packetService.sendPowerManagementPacket(bulb, false); | ||
replayAll(); | ||
|
||
bulb.switchOn(); | ||
bulb.switchOff(); | ||
|
||
verifyAll(); | ||
} | ||
|
||
} |