April 2011
Intermediate to advanced
356 pages
8h 55m
English
To make the scheduler work for multiple scheduled items, we’re going to need to be able to check the state of multiple lights, something our current LightControllerSpy cannot do. Let’s evolve the LightControllerSpy to remember the state of each light like this:
| tests/HomeAutomation/LightControllerSpyTest.cpp | |
| | TEST(LightControllerSpy, RememberAllLightStates) |
| | { |
| | LightController_On(0); |
| | LightController_Off(31); |
| | LONGS_EQUAL(LIGHT_ON, LightControllerSpy_GetLightState(0)); |
| | LONGS_EQUAL(LIGHT_OFF, LightControllerSpy_GetLightState(31)); |
| | } |
Add a new accessor to LightControllerSpy’s header file to allow any light’s state to be checked:
| tests/HomeAutomation/LightControllerSpy.h | |
| | int LightControllerSpy_GetLightState( |