/*
 * 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));
    Fake(Method(pin_controller, activate));

    items::detail::Lamp lamp(std::shared_ptr<DriverBoardPinController>(&pin_controller.get()), 0, 1, "test");

    WHEN("The lamp gets activated")
    {
      lamp.activate();

      THEN("It should call the pin_controller with itself")
      {
        // todo why doesnt this compile?
        //REQUIRE((bool) Verify(Method(pin_controller, activate).Using(&lamp)));
        AND_THEN("It should set its status to activated")
        {
          REQUIRE(lamp.is_activated());
        }
      }
    }
  }
}

SCENARIO("A Lamp gets deactivated")
{
  GIVEN("A Lamp")
  {
    Mock<DriverBoardPinController> pin_controller;
    Fake(Dtor(pin_controller));
    Fake(Method(pin_controller, deactivate));

    items::detail::Lamp lamp(std::shared_ptr<DriverBoardPinController>(&pin_controller.get()), 0, 1, "test");

    WHEN("The lamp gets deactivated")
    {
      lamp.deactivate();

      THEN("It should call the pin_controller with itself")
      {
        // todo why doesnt this compile?
        //REQUIRE((bool) Verify(Method(pin_controller, deactivate).Using(&lamp)));

        AND_THEN("It should set its status to deactivated")
        {
          REQUIRE_FALSE(lamp.is_activated());
        }
      }
    }
  }
}

