TEST(LightScheduler, ScheduleWeekEnd)
{
    LightScheduler_ScheduleTurnOn(3, WEEKEND, 1200);
    FakeTimeService_SetDay(FRIDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
    FakeTimeService_SetDay(SATURDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(3, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(1, LightControllerSpy_GetLastState());
    LightController_TurnOff(3);
    FakeTimeService_SetDay(SUNDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(3, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(1, LightControllerSpy_GetLastState());
    LightController_Create();
    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
TEST(FakeTimeService, Set)
{
  FakeTimeService_SetMinute(42);
  FakeTimeService_SetDay(SATURDAY);
  LONGS_EQUAL(42, getMinuteOfDay());
  LONGS_EQUAL(SATURDAY, getDayOfWeek());
}
TEST(TimeService, Set)
{
    FakeTimeService_SetMinute(42);
    LONGS_EQUAL(42, TimeService_GetMinute());
    FakeTimeService_SetDay(3);
    LONGS_EQUAL(3, TimeService_GetDay());
}
TEST(LightScheduler, ScheduleOnTodayNotTimeYet)
{
    LightScheduler_ScheduleTurnOn(3, EVERYDAY, 1200); 
    FakeTimeService_SetMinute(1199); 
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
TEST(LightScheduler, MultipleScheduledEventsDifferentTimes)
{
    LightScheduler_ScheduleTurnOff(4, MONDAY, 600);
    LightScheduler_ScheduleTurnOn(3, MONDAY, 500);

    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(500);

    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(3, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_ON, LightControllerSpy_GetLastState());

    FakeTimeService_SetMinute(600);

    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(4, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_OFF, LightControllerSpy_GetLastState());
}
TEST(LightScheduler, ScheduleWeekEndItsMonday)
{
    LightScheduler_ScheduleTurnOn(3, WEEKEND, 1200);
    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
TEST(LightScheduler, ScheduleOffTuesdayAndItsTuesdayAndItsTime)
{
    LightScheduler_ScheduleTurnOff(id, TUESDAY, 200);
    FakeTimeService_SetMinute(200);
    FakeTimeService_SetDay(TUESDAY);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(id, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_OFF, LightControllerSpy_GetLastState());
}
TEST(LightScheduler, ScheduleOnEverydayItsTime)
{
    LightScheduler_ScheduleTurnOn(id, EVERYDAY, 200);
    FakeTimeService_SetMinute(200);
    FakeTimeService_SetDay(MONDAY);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(id, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_ON, LightControllerSpy_GetLastState());
}
TEST(LightScheduler, WeekdayScheduleIsOperatedOnMonday)
{
    LightScheduler_ScheduleTurnOn(3, WEEKDAY, 1200);
    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(3, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_ON, LightControllerSpy_GetLastState());
}
Esempio n. 10
0
TEST(LightScheduler, WeekdayScheduleNotOperatedOnSunday)
{
    LightScheduler_ScheduleTurnOn(3, WEEKDAY, 1200);
    FakeTimeService_SetDay(SUNDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
Esempio n. 11
0
TEST(LightScheduler, ScheduleWeekEndItsSunday)
{
    LightScheduler_ScheduleTurnOn(6, WEEKEND, 1200);
    FakeTimeService_SetDay(SUNDAY);
    FakeTimeService_SetMinute(1200);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(6, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(1, LightControllerSpy_GetLastState());
}
Esempio n. 12
0
TEST(LightScheduler, ScheduleOnWeekdayAndItsSaturdayAndItsTime)
{
    LightScheduler_ScheduleTurnOn(id, WEEKDAY, 1000);

    FakeTimeService_SetMinute(1000);
    FakeTimeService_SetDay(SATURDAY);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
Esempio n. 13
0
TEST(LightScheduler, ScheduleOffWeekendAndItsSaturdayAndItsTime)
{
    LightScheduler_ScheduleTurnOff(id, WEEKEND, 200);

    FakeTimeService_SetMinute(200);
    FakeTimeService_SetDay(SATURDAY);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(id, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_OFF, LightControllerSpy_GetLastState());
}
Esempio n. 14
0
TEST(LightScheduler, ScheduleOnTuesdayAndItsNotTuesdayButItsTime)
{
    LightScheduler_ScheduleTurnOn(id, TUESDAY, 100);

    FakeTimeService_SetMinute(100);
    FakeTimeService_SetDay(MONDAY);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
Esempio n. 15
0
TEST(LightScheduler, ScheduleEverydayNotTimeYet)
{
    LightScheduler_ScheduleTurnOn(id, EVERYDAY, 100);

    FakeTimeService_SetMinute(99);
    FakeTimeService_SetDay(MONDAY);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
Esempio n. 16
0
TEST(LightScheduler, NoScheduleNothingHappens)
{
    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(100);

    LightScheduler_Wakeup();

    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
TEST(FakeTimeService, Set)
{
	Time time;
	/**N こんな風に、事前にメモリ上に時間をセットしてからテストする */
	FakeTimeService_SetMinute(42);
	FakeTimeService_SetDay(SATURDAY);

	LONGS_EQUAL(TIME_UNKNOWN, time.minuteOfDay);
	LONGS_EQUAL(TIME_UNKNOWN, time.dayOfWeek);
}
Esempio n. 18
0
TEST(LightScheduler, ScheduleOnWeekdayAndItsFridayAndItsTime)
{
    LightScheduler_ScheduleTurnOn(id, WEEKDAY, 1000);

    FakeTimeService_SetMinute(1000);
    FakeTimeService_SetDay(FRIDAY);
    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(id, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_ON, LightControllerSpy_GetLastState());
}
Esempio n. 19
0
TEST(LightScheduler, ScheduleOffEverydayItsTime)
{
    LightScheduler_ScheduleTurnOff(3, EVERYDAY, 1200);
    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(1200);

    LightScheduler_Wakeup();

    TEST_ASSERT_EQUAL(3, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_OFF, LightControllerSpy_GetLastState());
}
Esempio n. 20
0
TEST(LightScheduler, MultipleScheduledEventsSameTime)
{
    LightScheduler_ScheduleTurnOff(4, MONDAY, 500);
    LightScheduler_ScheduleTurnOn(3, MONDAY, 500);

    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(500);

    LightScheduler_WakeUp();
    TEST_ASSERT_EQUAL(2, FakeLightController_GetEventCounts());
}
Esempio n. 21
0
TEST(LightScheduler, ScheduleTwoEventsAtTheSameTIme)
{
    LightScheduler_ScheduleTurnOn(3, WEEKDAY, 1200);
    LightScheduler_ScheduleTurnOn(12, WEEKDAY, 1200);
    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(1200);

    LightScheduler_WakeUp();

    TEST_ASSERT_EQUAL(LIGHT_ON, LightControllerSpy_GetLightState(3));
    TEST_ASSERT_EQUAL(LIGHT_ON, LightControllerSpy_GetLightState(12));
}
Esempio n. 22
0
TEST(LightScheduler, RemoveScheduledEvent)
{
    LightScheduler_ScheduleTurnOn(6, MONDAY, 600);
    LightScheduler_ScheduleRemove(6, MONDAY, 600);

    FakeTimeService_SetDay(MONDAY);
    FakeTimeService_SetMinute(6000);

    LightScheduler_WakeUp();

    TEST_ASSERT_EQUAL(LIGHT_ID_UNKNOWN, LightControllerSpy_GetLastId());
    TEST_ASSERT_EQUAL(LIGHT_STATE_UNKNOWN, LightControllerSpy_GetLastState());
}
 void setTimeTo(int day, int minute)
 {
     FakeTimeService_SetDay(day);
     FakeTimeService_SetMinute(minute);
 }