Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
Ashlesh Gawande | 0cf4b60 | 2019-01-18 15:58:17 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2019, The University of Memphis |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 4 | * |
| 5 | * This file is part of PSync. |
| 6 | * See AUTHORS.md for complete list of PSync authors and contributors. |
| 7 | * |
| 8 | * PSync is free software: you can redistribute it and/or modify it under the terms |
Ashlesh Gawande | 0cf4b60 | 2019-01-18 15:58:17 -0600 | [diff] [blame] | 9 | * of the GNU Lesser General Public License as published by the Free Software Foundation, |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * PSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
Ashlesh Gawande | 0cf4b60 | 2019-01-18 15:58:17 -0600 | [diff] [blame] | 14 | * PURPOSE. See the GNU Lesser General Public License for more details. |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 15 | * |
Ashlesh Gawande | 0cf4b60 | 2019-01-18 15:58:17 -0600 | [diff] [blame] | 16 | * You should have received a copy of the GNU Lesser General Public License along with |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 17 | * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | **/ |
| 19 | |
Ashlesh Gawande | 78b94ad | 2018-12-13 15:29:19 -0600 | [diff] [blame] | 20 | #include "PSync/consumer.hpp" |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 21 | |
| 22 | #include <boost/test/unit_test.hpp> |
| 23 | #include <ndn-cxx/name.hpp> |
| 24 | #include <ndn-cxx/util/dummy-client-face.hpp> |
| 25 | |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 26 | namespace psync { |
| 27 | |
| 28 | using namespace ndn; |
| 29 | using namespace std; |
| 30 | |
| 31 | BOOST_AUTO_TEST_SUITE(TestConsumer) |
| 32 | |
| 33 | BOOST_AUTO_TEST_CASE(Constructor) |
| 34 | { |
| 35 | util::DummyClientFace face({true, true}); |
| 36 | BOOST_REQUIRE_NO_THROW(Consumer(Name("/psync"), |
| 37 | face, |
Ashlesh Gawande | a929647 | 2018-08-04 08:21:39 -0500 | [diff] [blame] | 38 | [] (const vector<Name>&) {}, |
| 39 | [] (const vector<MissingDataInfo>&) {}, |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 40 | 40, |
| 41 | 0.001)); |
| 42 | } |
| 43 | |
| 44 | BOOST_AUTO_TEST_CASE(AddSubscription) |
| 45 | { |
| 46 | util::DummyClientFace face({true, true}); |
| 47 | Consumer consumer(Name("/psync"), face, |
Ashlesh Gawande | a929647 | 2018-08-04 08:21:39 -0500 | [diff] [blame] | 48 | [] (const vector<Name>&) {}, |
| 49 | [] (const vector<MissingDataInfo>&) {}, |
Ashlesh Gawande | 0b2897e | 2018-06-20 14:40:47 -0500 | [diff] [blame] | 50 | 40, 0.001); |
| 51 | |
| 52 | Name subscription("test"); |
| 53 | |
| 54 | BOOST_CHECK(!consumer.isSubscribed(subscription)); |
| 55 | BOOST_CHECK(consumer.addSubscription(subscription)); |
| 56 | BOOST_CHECK(!consumer.addSubscription(subscription)); |
| 57 | } |
| 58 | |
| 59 | BOOST_AUTO_TEST_SUITE_END() |
| 60 | |
| 61 | } // namespace psync |