Add unit tests for CancelResponse in ProtocolClient 25/238625/6
authorZofia Abramowska <z.abramowska@samsung.com>
Wed, 15 Jul 2020 16:43:22 +0000 (18:43 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Wed, 12 Aug 2020 08:59:49 +0000 (10:59 +0200)
Change-Id: If34ce28977fdf13e26a7d89c7a11cd9ce20a287a

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

index 840956a7c6e8a0b851eda1a6c84d565ad43d9407..2a25197da71a3d3afa6dcfd4f68882e4e567ee9e 100644 (file)
@@ -153,6 +153,7 @@ SET(CYNARA_TESTS_SOURCES
     common/protocols/agent/agentregisterresponse.cpp
     common/protocols/agent/protocolagent.cpp
     common/protocols/client/cancelrequest.cpp
+    common/protocols/client/cancelresponse.cpp
     common/protocols/client/checkrequest.cpp
     common/protocols/client/checkresponse.cpp
     common/protocols/client/monitorentriesputrequest.cpp
diff --git a/test/common/protocols/client/cancelresponse.cpp b/test/common/protocols/client/cancelresponse.cpp
new file mode 100644 (file)
index 0000000..88d0262
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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/client/cancelresponse.cpp
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       Tests for Cynara::CancelResponse usage in Cynara::ProtocolClient
+ */
+
+#include <gtest/gtest.h>
+
+#include <protocol/ProtocolClient.h>
+#include <response/CancelResponse.h>
+
+#include <ResponseTestHelper.h>
+#include <TestDataCollection.h>
+
+namespace {
+
+template<>
+void compare(const Cynara::CancelResponse &resp1, const Cynara::CancelResponse &resp2) {
+    EXPECT_EQ(resp1.sequenceNumber(), resp2.sequenceNumber());
+}
+
+} /* namespace anonymous */
+
+using namespace Cynara;
+using namespace ResponseTestHelper;
+using namespace TestDataCollection;
+
+/* *** compare by objects test cases *** */
+
+TEST(ProtocolClient, CancelResponsePositive) {
+    for (auto &sequenceNumber : SN::all) {
+        auto response = std::make_shared<CancelResponse>(sequenceNumber);
+        auto protocol = std::make_shared<ProtocolClient>();
+        testResponse(response, protocol);
+    }
+}
+
+TEST(ProtocolClient, CancelResponseBinaryPositive) {
+    for (auto &sequenceNumber : SN::all) {
+        auto response = std::make_shared<CancelResponse>(sequenceNumber);
+        auto protocol = std::make_shared<ProtocolClient>();
+        binaryTestResponse(response, protocol);
+    }
+}