11 #include <gtest/gtest.h>
12 #include <gmock/gmock.h>
14 using namespace ::testing;
15 using namespace ::
daq;
24 TEST(TestEventLog, Constructors) {
25 EXPECT_NO_THROW(EventLog());
28 TEST(TestObservableEventLog, Constructors) {
29 EXPECT_NO_THROW(ObservableEventLog());
32 TEST(TestObservableEventLog, ConvertibleToEventLog) {
33 auto observable_events = ObservableEventLog();
34 auto events1 =
static_cast<EventLog const&
>(observable_events);
35 auto events2 = observable_events.GetEventLog();
37 EXPECT_EQ(events1.events, events2.events);
40 TEST(TestObservableEventLog, ObserversAreInvokedWhenEventIsAdded) {
42 auto event = ErrorEvent(
"id",
"test error", {},
"origin");
44 EXPECT_CALL(mock_observer, CallOperator(EventLog::EventType(event)));
47 auto events = ObservableEventLog();
48 events.ConnectObserver(std::reference_wrapper(mock_observer));
49 events.AddEvent(event);
52 TEST(TestObservableEventLog, EventLogAreAddedToContainer) {
54 auto event = ErrorEvent(
"id",
"test error", {},
"origin");
57 auto events = ObservableEventLog();
58 EXPECT_EQ(events.GetEventContainer().size(), std::size_t(0));
59 events.AddEvent(event);
60 EXPECT_EQ(events.GetEventContainer().size(), std::size_t(1));
61 EXPECT_EQ(events.GetEventContainer()[0], EventLog::EventType(event));
64 TEST(TestErrorEvent, Comparison) {
66 auto event1 = ErrorEvent(
"id1",
"test error", {},
"origin");
67 auto event2 = ErrorEvent(
"id2",
"test error", {},
"origin");
70 EXPECT_EQ(event1, event1);
71 EXPECT_NE(event1, event2);
74 TEST(TestGenericEvent, Comparison) {
76 auto event1 = GenericEvent(
"id1",
"test error", {});
77 auto event2 = GenericEvent(
"id2",
"test error", {});
80 EXPECT_EQ(event1, event1);
81 EXPECT_NE(event1, event2);
86 auto event1 = ErrorEvent(
"id1",
"test error", {},
"origin");
87 auto event2 = GenericEvent(
"id2",
"test error", {});
91 ss << event1 << event2