made some stuff working 😠 @Jonas
This commit is contained in:
@@ -11,14 +11,15 @@
|
||||
|
||||
#include <map>
|
||||
#include <typeinfo>
|
||||
#include <thread>
|
||||
|
||||
|
||||
#define private public
|
||||
|
||||
#include "input/IEventNotifier.h"
|
||||
#include "input/EventNotifier.h"
|
||||
#include "input/DistributingEvent.h"
|
||||
#include "input/Detector.h"
|
||||
#include "input/IInputGPIOInterface.h"
|
||||
#include "input/detail/Detector.h"
|
||||
#include "input/detail/InputPinController.h"
|
||||
#include "utility/LoggerFactory.h"
|
||||
|
||||
|
||||
@@ -34,8 +35,8 @@ SCENARIO("Creating a Detector object", "")
|
||||
{
|
||||
LoggerFactory::CreateInputTestLogger();
|
||||
|
||||
Mock<IEventNotifier> event_notifier_mock;
|
||||
Mock<IInputGPIOInterface> gpio_interface_mock;
|
||||
Mock<EventNotifier> event_notifier_mock;
|
||||
Mock<InputPinController> gpio_interface_mock;
|
||||
|
||||
Fake(Dtor(gpio_interface_mock));
|
||||
When(Method(gpio_interface_mock, read_data)).AlwaysReturn(false);
|
||||
@@ -47,7 +48,7 @@ SCENARIO("Creating a Detector object", "")
|
||||
|
||||
WHEN("Detector is created")
|
||||
{
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events);
|
||||
detail::Detector detector(std::unique_ptr<InputPinController>(&gpio_interface_mock.get()), events);
|
||||
THEN("a thread should be created")
|
||||
{
|
||||
REQUIRE(typeid(detector.detect_thread).hash_code() == typeid(std::thread).hash_code());
|
||||
@@ -58,12 +59,12 @@ SCENARIO("Creating a Detector object", "")
|
||||
|
||||
SCENARIO("There are events at the input", "")
|
||||
{
|
||||
GIVEN("An IEventNofifier, three Events and an IInputGPIOInterface")
|
||||
GIVEN("An IEventNofifier, three Events and an InputPinController")
|
||||
{
|
||||
LoggerFactory::CreateInputTestLogger();
|
||||
|
||||
Mock<IEventNotifier> event_notifier_mock;
|
||||
Mock<IInputGPIOInterface> gpio_interface_mock;
|
||||
Mock<EventNotifier> event_notifier_mock;
|
||||
Mock<InputPinController> gpio_interface_mock;
|
||||
|
||||
Fake(Dtor(gpio_interface_mock));
|
||||
When(Method(gpio_interface_mock, read_data)).AlwaysDo([](char c){return c==2;});
|
||||
@@ -71,7 +72,7 @@ SCENARIO("There are events at the input", "")
|
||||
Fake(Dtor(event_notifier_mock));
|
||||
When(Method(event_notifier_mock, distribute_event)).AlwaysReturn();
|
||||
|
||||
std::shared_ptr<IEventNotifier> event_notifier;
|
||||
std::shared_ptr<EventNotifier> event_notifier;
|
||||
DistributingEvent event1(1, '1', "event 1", std::chrono::milliseconds(0), event_notifier);
|
||||
DistributingEvent event2(2, '2', "event 2", std::chrono::milliseconds(0), event_notifier);
|
||||
DistributingEvent event3(3, '3', "event 3", std::chrono::milliseconds(0), event_notifier);
|
||||
@@ -85,7 +86,7 @@ SCENARIO("There are events at the input", "")
|
||||
|
||||
WHEN("an event can be found at gpio interface")
|
||||
{
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events);
|
||||
detail::Detector detector(std::unique_ptr<InputPinController>(&gpio_interface_mock.get()), events);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
THEN("the event should be distributed")
|
||||
{
|
||||
@@ -99,12 +100,12 @@ SCENARIO("There are events at the input", "")
|
||||
|
||||
SCENARIO("There are events at the input but no suitable event in map", "")
|
||||
{
|
||||
GIVEN("An IEventNofifier, three Events and an IInputGPIOInterface")
|
||||
GIVEN("An IEventNofifier, three Events and an InputPinController")
|
||||
{
|
||||
LoggerFactory::CreateInputTestLogger();
|
||||
|
||||
Mock<IEventNotifier> event_notifier_mock;
|
||||
Mock<IInputGPIOInterface> gpio_interface_mock;
|
||||
Mock<EventNotifier> event_notifier_mock;
|
||||
Mock<InputPinController> gpio_interface_mock;
|
||||
|
||||
Fake(Dtor(gpio_interface_mock));
|
||||
When(Method(gpio_interface_mock, read_data)).AlwaysDo([](char c){return c==4;});
|
||||
@@ -112,7 +113,7 @@ SCENARIO("There are events at the input but no suitable event in map", "")
|
||||
Fake(Dtor(event_notifier_mock));
|
||||
When(Method(event_notifier_mock, distribute_event)).AlwaysReturn();
|
||||
|
||||
std::shared_ptr<IEventNotifier> event_notifier;
|
||||
std::shared_ptr<EventNotifier> event_notifier;
|
||||
DistributingEvent event1(1, '1', "event 1", std::chrono::milliseconds(0), event_notifier);
|
||||
DistributingEvent event2(2, '2', "event 2", std::chrono::milliseconds(0), event_notifier);
|
||||
DistributingEvent event3(3, '3', "event 3", std::chrono::milliseconds(0), event_notifier);
|
||||
@@ -125,7 +126,7 @@ SCENARIO("There are events at the input but no suitable event in map", "")
|
||||
|
||||
WHEN("an event can be found at gpio interface")
|
||||
{
|
||||
Detector detector(std::unique_ptr<IInputGPIOInterface>(&gpio_interface_mock.get()), events);
|
||||
detail::Detector detector(std::unique_ptr<InputPinController>(&gpio_interface_mock.get()), events);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
THEN("the event should be distributed")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user