/*
 * TestOutputDriver.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/DisplayController.h>
#include "output/items/Solenoid.h"
#include "output/items/Lamp.h"
#include "output/items/Sound.h"
#include "output/items/Display.h"

// testing purposes
#define private public

#include "output/OutputDriver.h"

using namespace flippR_driver;
using namespace flippR_driver::output;
using namespace fakeit;


SCENARIO("The OutputDriver should (de)activates the displays")
{
  GIVEN("An OutputDriver")
  {
    Mock<output::DisplayController> display_controller;
    Fake(Method(display_controller, activate_displays));
    Fake(Method(display_controller, deactivate_displays));

    std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
    std::map<std::string, std::shared_ptr<items::Lamp>> lamps;
    std::map<std::string, std::shared_ptr<items::Sound>> sounds;
    std::map<std::string, std::shared_ptr<items::Flipper>> flippers;
    std::map<uint8_t, std::shared_ptr<output::items::Display>> displays;

    output::OutputDriver output_driver(std::unique_ptr<output::DisplayController>(&display_controller.get()), solenoids, lamps, sounds, flippers, displays);

    WHEN("The displays get activated")
    {
      output_driver.activate_displays();
      THEN("The display controller should be called")
      {
        REQUIRE((bool)Verify(Method(display_controller, activate_displays)));
      }
    }

    WHEN("The displays get deactivated")
    {
      output_driver.deactivate_displays();
      THEN("The display controller should be called")
      {
        REQUIRE((bool)Verify(Method(display_controller, deactivate_displays)));
      }
    }
  }
}


SCENARIO("The OutputDriver should return a list of all items")
{
  GIVEN("An OutputDriver with some items")
  {
    Mock<output::DisplayController> display_controller;

    std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
    std::map<std::string, std::shared_ptr<items::Lamp>> lamps;
    std::map<std::string, std::shared_ptr<items::Sound>> sounds;
    std::map<uint8_t, std::shared_ptr<output::items::Display>> displays;
  }

}