blob: 97adde3cc673fff8dbec511140d9bde3d9b63a0f [file] [log] [blame]
Ashlesh Gawande0b2897e2018-06-20 14:40:47 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2018, The University of Memphis
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
9 * of the GNU General Public License as published by the Free Software Foundation,
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
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20#include "consumer.hpp"
21
22#include <boost/test/unit_test.hpp>
23#include <ndn-cxx/name.hpp>
24#include <ndn-cxx/util/dummy-client-face.hpp>
25
26#include <iostream>
27
28namespace psync {
29
30using namespace ndn;
31using namespace std;
32
33BOOST_AUTO_TEST_SUITE(TestConsumer)
34
35BOOST_AUTO_TEST_CASE(Constructor)
36{
37 util::DummyClientFace face({true, true});
38 BOOST_REQUIRE_NO_THROW(Consumer(Name("/psync"),
39 face,
Ashlesh Gawandea9296472018-08-04 08:21:39 -050040 [] (const vector<Name>&) {},
41 [] (const vector<MissingDataInfo>&) {},
Ashlesh Gawande0b2897e2018-06-20 14:40:47 -050042 40,
43 0.001));
44}
45
46BOOST_AUTO_TEST_CASE(AddSubscription)
47{
48 util::DummyClientFace face({true, true});
49 Consumer consumer(Name("/psync"), face,
Ashlesh Gawandea9296472018-08-04 08:21:39 -050050 [] (const vector<Name>&) {},
51 [] (const vector<MissingDataInfo>&) {},
Ashlesh Gawande0b2897e2018-06-20 14:40:47 -050052 40, 0.001);
53
54 Name subscription("test");
55
56 BOOST_CHECK(!consumer.isSubscribed(subscription));
57 BOOST_CHECK(consumer.addSubscription(subscription));
58 BOOST_CHECK(!consumer.addSubscription(subscription));
59}
60
61BOOST_AUTO_TEST_SUITE_END()
62
63} // namespace psync