Skip to content
Snippets Groups Projects
Unverified Commit 304681a7 authored by Dimitrios Stoupis's avatar Dimitrios Stoupis
Browse files

Added sections for all the required tests

parent 7a6a877d
No related branches found
No related tags found
No related merge requests found
...@@ -7,12 +7,15 @@ ...@@ -7,12 +7,15 @@
namespace unit_test { namespace unit_test {
struct Tester { struct Tester {
TimeBasedSchedulingService gen; TimeBasedSchedulingService gen;
static bool executionFunctionStatus(TimeBasedSchedulingService tmService) { static bool executionFunctionStatus(TimeBasedSchedulingService tmService) {
return tmService.executionFunctionStatus; return tmService.executionFunctionStatus;
} }
static uint8_t currentNumberOfActivities(TimeBasedSchedulingService tmService) { static uint8_t currentNumberOfActivities(TimeBasedSchedulingService tmService) {
return tmService.currentNumberOfActivities; return tmService.currentNumberOfActivities;
} }
static auto scheduledActivities(TimeBasedSchedulingService tmService) { static auto scheduledActivities(TimeBasedSchedulingService tmService) {
return tmService.scheduledActivities; return tmService.scheduledActivities;
} }
...@@ -40,44 +43,93 @@ TEST_CASE("TC[11,2]", "[service][st11]") { ...@@ -40,44 +43,93 @@ TEST_CASE("TC[11,2]", "[service][st11]") {
CHECK(not unit_test::Tester::executionFunctionStatus(timeSchedulingService)); CHECK(not unit_test::Tester::executionFunctionStatus(timeSchedulingService));
} }
TEST_CASE("TC[11,4]", "[service][st11]") { TEST_CASE("ST[11] Integrated test", "[service][st11]") {
Message receivedMessage(11, 4, Message::TC, 1), #define NUMBER_OF_INSTRUCTIONS 4 // The number of total instructions in the packet
testMessage1(6, 5, Message::TC, 4), testMessage2(4, 5, Message::TC, 6),
testMessage3(3, 2, Message::TC, 7); Message testMessage1(6, 5, Message::TC, 4), testMessage2(4, 5, Message::TC, 6),
testMessage3(3, 2, Message::TC, 7), testMessage4(12, 23, Message::TC, 5);
MessageParser msgParser; MessageParser msgParser;
TimeBasedSchedulingService timeBasedSchedulingService;
SECTION("TC[11,4] Activity insertion") {
Message receivedMessage(11, 4, Message::TC, 1);
receivedMessage.appendUint16(NUMBER_OF_INSTRUCTIONS);
// Test activity 1
testMessage1.appendUint16(4253); // Append dummy data
receivedMessage.appendUint32(1556435); // todo: Append actual time
receivedMessage.appendString(msgParser.convertTCToStr(testMessage1));
// Test activity 2
testMessage2.appendUint16(45667); // Append dummy data
receivedMessage.appendUint32(1957232); // todo: Append actual time
receivedMessage.appendString(msgParser.convertTCToStr(testMessage2));
// Test activity 3
testMessage3.appendUint16(456); // Append dummy data
receivedMessage.appendUint32(1726435); // todo: Append actual time
receivedMessage.appendString(msgParser.convertTCToStr(testMessage3));
// Test activity 4
testMessage4.appendUint16(934); // Append dummy data
receivedMessage.appendUint32(17248435); // todo: Append actual time
receivedMessage.appendString(msgParser.convertTCToStr(testMessage4));
// Insert activities in the schedule. They have to be inserted sorted
timeBasedSchedulingService.insertActivities(receivedMessage);
auto scheduledActivities = unit_test::Tester::scheduledActivities(
timeBasedSchedulingService);
CHECK(scheduledActivities.size() == 4);
REQUIRE(scheduledActivities.at(0).requestReleaseTime == 1556435);
REQUIRE(scheduledActivities.at(1).requestReleaseTime == 1726435);
REQUIRE(scheduledActivities.at(2).requestReleaseTime == 1957232);
REQUIRE(scheduledActivities.at(3).requestReleaseTime == 17248435);
REQUIRE(scheduledActivities.at(0).request == testMessage1);
REQUIRE(scheduledActivities.at(1).request == testMessage3);
REQUIRE(scheduledActivities.at(2).request == testMessage2);
REQUIRE(scheduledActivities.at(3).request == testMessage4);
}
receivedMessage.appendUint16(3); // Number od instructions SECTION("TC[11,5] Activity deletion by ID") {
Message receivedMessage(11, 5, Message::TC, 1);
receivedMessage.appendUint16(NUMBER_OF_INSTRUCTIONS);
// Test activity 1 //timeBasedSchedulingService.detailReporActivitiesByID();
testMessage1.appendUint16(4253); // todo: Append dummy data }
receivedMessage.appendUint32(1556435); // todo: Append actual time
receivedMessage.appendString(msgParser.convertTCToStr(testMessage1));
// Test activity 2 SECTION("TC[11,7] Time shift activities by ID") {
testMessage2.appendUint16(45667); // todo: Append dummy data Message receivedMessage(11, 7, Message::TC, 1);
receivedMessage.appendUint32(1); // todo: Append actual time receivedMessage.appendUint16(NUMBER_OF_INSTRUCTIONS);
receivedMessage.appendString(msgParser.convertTCToStr(testMessage2));
// Test activity 3 //timeBasedSchedulingService.detailReporActivitiesByID();
testMessage3.appendUint16(456); // todo: Append dummy data }
receivedMessage.appendUint32(1726435); // todo: Append actual time
receivedMessage.appendString(msgParser.convertTCToStr(testMessage3));
SECTION("TC[11,9] Detail report scheduled activities by ID") {
Message receivedMessage(11, 9, Message::TC, 1);
receivedMessage.appendUint16(NUMBER_OF_INSTRUCTIONS);
TimeBasedSchedulingService timeBasedSchedulingService; //timeBasedSchedulingService.detailReporActivitiesByID();
timeBasedSchedulingService.insertActivities(receivedMessage); }
auto scheduledActivities = unit_test::Tester::scheduledActivities(timeBasedSchedulingService); SECTION("TC[11,12] Summary report scheduled activities by ID") {
CHECK(scheduledActivities.size() == 2); // Two will be inserted (Second is invalid) Message receivedMessage(11, 12, Message::TC, 1);
REQUIRE(scheduledActivities.at(0).requestReleaseTime == 1556435); receivedMessage.appendUint16(NUMBER_OF_INSTRUCTIONS);
REQUIRE(scheduledActivities.at(1).requestReleaseTime == 1726435);
//CHECK(memcmp(&scheduledActivities.at(0).request, &testMessage2, sizeof(Message))); //timeBasedSchedulingService.detailReporActivitiesByID();
std::cout << scheduledActivities.at(0).request.data << " " << testMessage1.data << std::endl; }
if (scheduledActivities.at(0).request == testMessage1) {
std::cout << "Message are the same!!" << std::endl; SECTION("TC[11,15] Time shift all scheduled activities") {
Message receivedMessage(11, 15, Message::TC, 1);
receivedMessage.appendUint16(NUMBER_OF_INSTRUCTIONS);
//timeBasedSchedulingService.detailReporActivitiesByID();
}
SECTION("TC[11,16] Detail report all scheduled activities") {
Message receivedMessage(11, 16, Message::TC, 1);
receivedMessage.appendUint16(NUMBER_OF_INSTRUCTIONS);
//timeBasedSchedulingService.detailReporActivitiesByID();
} }
//CHECK(scheduledActivities.at(0).request == testMessage1);
//REQUIRE(scheduledActivities.at(2).requestReleaseTime == 1556435);
//REQUIRE(scheduledActivities.at(0).requestID.applicationID == 45);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment