blob: 98944684d6e6c5c0a5a2b09f58df8736e9557a57 [file] [log] [blame]
Junxiao Shi034c1882016-06-24 18:06:51 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016 Regents of the University of California.
4 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
22#ifndef NDN_TESTS_MANAGEMENT_NFD_CONTROLLER_FIXTURE_HPP
23#define NDN_TESTS_MANAGEMENT_NFD_CONTROLLER_FIXTURE_HPP
24
25#include "boost-test.hpp"
26#include "util/dummy-client-face.hpp"
27#include "../identity-management-time-fixture.hpp"
28
29namespace ndn {
30namespace nfd {
31namespace tests {
32
33using namespace ndn::tests;
34
Alexander Afanasyeve4f8c3b2016-06-23 16:03:48 -070035class ControllerFixture : public IdentityManagementTimeFixture
Junxiao Shi034c1882016-06-24 18:06:51 +000036{
37protected:
38 ControllerFixture()
Alexander Afanasyeve4f8c3b2016-06-23 16:03:48 -070039 : face(io, m_keyChain)
Junxiao Shi034c1882016-06-24 18:06:51 +000040 , controller(face, m_keyChain)
41 , failCallback(bind(&ControllerFixture::fail, this, _1, _2))
42 {
43 Name identityName("/localhost/ControllerFixture");
44 if (this->addIdentity(identityName)) {
45 m_keyChain.setDefaultIdentity(identityName);
46 }
47 else {
48 BOOST_FAIL("cannot create identity");
49 }
50 }
51
52private:
53 void
54 fail(uint32_t code, const std::string& reason)
55 {
56 failCodes.push_back(code);
57 }
58
59protected:
60 ndn::util::DummyClientFace face;
61 Controller controller;
62 Controller::CommandFailCallback failCallback;
63 std::vector<uint32_t> failCodes;
64};
65
66} // namespace tests
67} // namespace nfd
68} // namespace ndn
69
70#endif // NDN_TESTS_MANAGEMENT_NFD_CONTROLLER_FIXTURE_HPP