From d8b160dc62106fb3e461477f8c1134fb52004084 Mon Sep 17 00:00:00 2001
From: athatheocsd <athatheo@csd.auth.gr>
Date: Mon, 31 Dec 2018 23:44:20 +0200
Subject: [PATCH] TC[19,2], TC[19,3] completed

---
 src/main.cpp                         |  10 ---
 test/Services/EventActionService.cpp | 103 ++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 11 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index 580f97e1..b5e55371 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -205,22 +205,12 @@ int main() {
 	EventActionService eventActionService;
 	char checkstring[256];
 	Message eventActionDefinition(19, 1, Message::TC, 1);
-	eventActionDefinition.appendUint16(2);
 	eventActionDefinition.appendEnum16(0);
 	eventActionDefinition.appendEnum16(2);
 	String<64> TCdata = "hi";
 
 	eventActionDefinition.appendString(TCdata);
 	eventActionService.addEventActionDefinitions(eventActionDefinition);
-//	message.readString(checkstring, 2);
-//	std::cout << eventActionService.eventActionDefinitionArray[0].empty;//
-	// .compare
-	// (checkstring)
-	// ==0);
-//	CHECK(message.readEnum16() == 1);
-//	CHECK(message.readEnum16() == 3);
-//	message.readString(checkstring, 3);
-//	CHECK(eventActionService.eventActionDefinitionArray[1].request.compare(data) == 0);
 
 	return 0;
 }
diff --git a/test/Services/EventActionService.cpp b/test/Services/EventActionService.cpp
index cb23ba3e..fe82e81d 100644
--- a/test/Services/EventActionService.cpp
+++ b/test/Services/EventActionService.cpp
@@ -39,11 +39,112 @@ TEST_CASE("Add event-action definitions TC[19,1]", "[service][st09]") {
 }
 
 TEST_CASE("Delete event-action definitions TC[19,2]", "[service][st09]") {
+	EventActionService eventActionService;
+	char checkString[256];
+	Message message0(19, 1, Message::TC, 0);
+	message0.appendEnum16(1);
+	message0.appendEnum16(0);
+	String<64> data = "0";
+	message0.appendString(data);
+	eventActionService.addEventActionDefinitions(message0);
+	Message message1(19, 1, Message::TC, 0);
+	message1.appendEnum16(1);
+	message1.appendEnum16(1);
+	data = "1";
+	message1.appendString(data);
+	eventActionService.addEventActionDefinitions(message1);
+	Message message2(19, 1, Message::TC, 0);
+	message2.appendEnum16(1);
+	message2.appendEnum16(2);
+	data = "2";
+	message2.appendString(data);
+	eventActionService.addEventActionDefinitions(message2);
+	Message message3(19, 1, Message::TC, 0);
+	message3.appendEnum16(1);
+	message3.appendEnum16(3);
+	data = "3";
+	message3.appendString(data);
+	eventActionService.addEventActionDefinitions(message3);
+	Message message4(19, 1, Message::TC, 0);
+	message4.appendEnum16(1);
+	message4.appendEnum16(4);
+	data = "4";
+	message4.appendString(data);
+	eventActionService.addEventActionDefinitions(message4);
+
+	Message message(19, 2, Message::TC, 0);
+	message.appendUint16(2);
+	message.appendEnum16(1);
+	message.appendEnum16(4);
+	message.appendEnum16(1);
+	message.appendEnum16(2);
+	eventActionService.deleteEventActionDefinitions(message);
 
+	CHECK(eventActionService.eventActionDefinitionArray[0].empty == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[0].applicationId == 1);
+	CHECK(eventActionService.eventActionDefinitionArray[0].eventDefinitionID == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[0].request.compare("0") == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[1].empty == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[1].applicationId == 1);
+	CHECK(eventActionService.eventActionDefinitionArray[1].eventDefinitionID == 1);
+	CHECK(eventActionService.eventActionDefinitionArray[1].request.compare("1") == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[2].empty == 1);
+	CHECK(eventActionService.eventActionDefinitionArray[2].applicationId == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[2].eventDefinitionID == 65535);
+	CHECK(eventActionService.eventActionDefinitionArray[2].request.compare("") == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[3].empty == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[3].applicationId == 1);
+	CHECK(eventActionService.eventActionDefinitionArray[3].eventDefinitionID == 3);
+	CHECK(eventActionService.eventActionDefinitionArray[3].request.compare("3") == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[4].empty == 1);
+	CHECK(eventActionService.eventActionDefinitionArray[4].applicationId == 0);
+	CHECK(eventActionService.eventActionDefinitionArray[4].eventDefinitionID == 65535);
+	CHECK(eventActionService.eventActionDefinitionArray[4].request.compare("") == 0);
 }
 
 TEST_CASE("Delete all event-action definitions TC[19,3]", "[service][st09]") {
-
+	EventActionService eventActionService;
+	char checkString[256];
+	Message message0(19, 1, Message::TC, 0);
+	message0.appendEnum16(1);
+	message0.appendEnum16(0);
+	String<64> data = "0";
+	message0.appendString(data);
+	eventActionService.addEventActionDefinitions(message0);
+	Message message1(19, 1, Message::TC, 0);
+	message1.appendEnum16(1);
+	message1.appendEnum16(1);
+	data = "1";
+	message1.appendString(data);
+	eventActionService.addEventActionDefinitions(message1);
+	Message message2(19, 1, Message::TC, 0);
+	message2.appendEnum16(1);
+	message2.appendEnum16(2);
+	data = "2";
+	message2.appendString(data);
+	eventActionService.addEventActionDefinitions(message2);
+	Message message3(19, 1, Message::TC, 0);
+	message3.appendEnum16(1);
+	message3.appendEnum16(3);
+	data = "3";
+	message3.appendString(data);
+	eventActionService.addEventActionDefinitions(message3);
+	Message message4(19, 1, Message::TC, 0);
+	message4.appendEnum16(1);
+	message4.appendEnum16(4);
+	data = "4";
+	message4.appendString(data);
+	eventActionService.addEventActionDefinitions(message4);
+
+	Message message(19, 3, Message::TC, 0);
+	eventActionService.deleteAllEventActionDefinitions(message);
+
+	for (int i = 0; i < 256; i++){
+		CHECK(eventActionService.eventActionDefinitionArray[i].empty == 1);
+		CHECK(eventActionService.eventActionDefinitionArray[i].applicationId == 0);
+		CHECK(eventActionService.eventActionDefinitionArray[i].eventDefinitionID == 65535);
+		CHECK(eventActionService.eventActionDefinitionArray[i].request.compare("") == 0);
+	}
 }
 
 TEST_CASE("Enable event-action definitions TC[19,4]", "[service][st09]") {
-- 
GitLab