Add unit tests for AgentRegisterResponse in ProtocolAgent 70/235570/9
authorZofia Abramowska <z.abramowska@samsung.com>
Fri, 5 Jun 2020 11:25:56 +0000 (13:25 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Tue, 4 Aug 2020 14:40:21 +0000 (16:40 +0200)
Change-Id: Idbdef1ab3315dc4e3238e7fc57f334acdc7583e3

test/CMakeLists.txt
test/common/protocols/agent/agentregisterresponse.cpp [new file with mode: 0644]

index 6891029efaa97c1287e43eb816674de0e4dea6d5..7f36ae7f83f5b63246bccd8d0f777b2e0f8f8994 100644 (file)
@@ -149,6 +149,7 @@ SET(CYNARA_TESTS_SOURCES
     common/protocols/agent/agentactionrequest.cpp
     common/protocols/agent/agentactionresponse.cpp
     common/protocols/agent/agentregisterrequest.cpp
+    common/protocols/agent/agentregisterresponse.cpp
     common/protocols/agent/protocolagent.cpp
     common/protocols/monitor/flushrequest.cpp
     common/protocols/monitor/getentriesrequest.cpp
diff --git a/test/common/protocols/agent/agentregisterresponse.cpp b/test/common/protocols/agent/agentregisterresponse.cpp
new file mode 100644 (file)
index 0000000..bea67cf
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is licensed under the terms of MIT License or the Apache License
+ * Version 2.0 of your choice. See the LICENSE.MIT file for MIT license details.
+ * See the LICENSE file or the notice below for Apache License Version 2.0
+ * details.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/**
+ * @file        test/common/protocols/agent/agentregisterresponse.cpp
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       Tests for Cynara::AgentRegisterResponse usage in Cynara::ProtocolAgent
+ */
+
+#include <gtest/gtest.h>
+
+#include <protocol/ProtocolAgent.h>
+#include <response/AgentRegisterResponse.h>
+
+#include <NegativeTestHelper.h>
+#include <ResponseTestHelper.h>
+#include <TestDataCollection.h>
+
+namespace {
+
+template<>
+void compare(const Cynara::AgentRegisterResponse &resp1,
+             const Cynara::AgentRegisterResponse &resp2)
+{
+    EXPECT_EQ(resp1.m_code, resp2.m_code);
+    EXPECT_EQ(resp1.sequenceNumber(), resp2.sequenceNumber());
+}
+
+const Cynara::AgentRegisterResponse::Code ALL_CODES[] = {
+    Cynara::AgentRegisterResponse::DONE, Cynara::AgentRegisterResponse::ERROR,
+    Cynara::AgentRegisterResponse::REJECTED
+};
+
+} /* namespace anonymous */
+
+using namespace Cynara;
+using namespace NegativeTestHelper;
+using namespace ResponseTestHelper;
+using namespace TestDataCollection;
+
+/* *** compare by objects test cases *** */
+
+TEST(ProtocolAgent, AgentRegisterResponsePositive)
+{
+    for (auto &code : ALL_CODES) {
+        for (auto &sequenceNumber : SN::all) {
+            auto response = std::make_shared<AgentRegisterResponse>(code, sequenceNumber);
+            auto protocol = std::make_shared<ProtocolAgent>();
+            testResponse(response, protocol);
+        }
+    }
+}
+
+TEST(ProtocolAgent, AgentRegisterResponseBinaryPositive)
+{
+    for (auto &code : ALL_CODES) {
+        for (auto &sequenceNumber : SN::all) {
+            auto response = std::make_shared<AgentRegisterResponse>(code, sequenceNumber);
+            auto protocol = std::make_shared<ProtocolAgent>();
+            binaryTestResponse(response, protocol);
+        }
+    }
+}