61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
/*
|
|
* TestLamp.cpp
|
|
*
|
|
* Created on: Aug 7, 2018
|
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
*/
|
|
|
|
#include "catch.hpp"
|
|
#include "fakeit.hpp"
|
|
|
|
#include "utility/LoggerFactory.h"
|
|
|
|
#include "output/items/detail/Lamp.h"
|
|
|
|
using namespace flippR_driver::output;
|
|
using namespace fakeit;
|
|
|
|
SCENARIO("A Lamp gets activated")
|
|
{
|
|
GIVEN("A Lamp")
|
|
{
|
|
Mock<DriverBoardPinController> pin_controller;
|
|
Fake(Dtor(pin_controller));
|
|
When(Method(pin_controller, activate)).AlwaysReturn();
|
|
|
|
items::detail::Lamp lamp(std::make_shared<DriverBoardPinController>(pin_controller), 0, 0);
|
|
|
|
WHEN("The lamp gets activated")
|
|
{
|
|
lamp.activate();
|
|
|
|
THEN("It should call the pin_controller with itself")
|
|
{
|
|
REQUIRE((bool) Verify(Method(pin_controller, activate).Using(&lamp)));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SCENARIO("A Lamp gets deactivated")
|
|
{
|
|
GIVEN("A Lamp")
|
|
{
|
|
Mock<DriverBoardPinController> pin_controller;
|
|
Fake(Dtor(pin_controller));
|
|
When(Method(pin_controller, deactivate)).AlwaysReturn();
|
|
|
|
items::detail::Lamp lamp(std::make_shared<DriverBoardPinController>(pin_controller), 0, 0);
|
|
|
|
WHEN("The lamp gets deactivated")
|
|
{
|
|
lamp.deactivate();
|
|
|
|
THEN("It should call the pin_controller with itself")
|
|
{
|
|
REQUIRE((bool) Verify(Method(pin_controller, deactivate).Using(&lamp)));
|
|
}
|
|
}
|
|
}
|
|
}
|