/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2015,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "tests/test-common.hpp"
#include "rib-test-common.hpp"

#include "rib/rib-update.hpp"
#include "rib/rib-update-batch.hpp"

namespace nfd {
namespace rib {
namespace tests {

BOOST_FIXTURE_TEST_SUITE(RibRibUpdate, nfd::tests::BaseFixture)

BOOST_AUTO_TEST_CASE(BatchBasic)
{
  const uint64_t faceId = 1;

  RibUpdateBatch batch(faceId);

  Route routeRegister = createRoute(faceId, 128, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);

  RibUpdate registerUpdate;
  registerUpdate.setAction(RibUpdate::REGISTER)
                .setName("/a")
                .setRoute(routeRegister);

  batch.add(registerUpdate);

  BOOST_CHECK_EQUAL(batch.getFaceId(), faceId);

  Route routeUnregister = createRoute(faceId, 0, 0, ndn::nfd::ROUTE_FLAG_CAPTURE);

  RibUpdate unregisterUpdate;
  unregisterUpdate.setAction(RibUpdate::UNREGISTER)
                  .setName("/a/b")
                  .setRoute(routeUnregister);

  batch.add(unregisterUpdate);

  BOOST_REQUIRE_EQUAL(batch.size(), 2);
  RibUpdateBatch::const_iterator it = batch.begin();

  BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::REGISTER);
  BOOST_CHECK_EQUAL(it->getName(), "/a");
  BOOST_CHECK_EQUAL(it->getRoute(), routeRegister);

  ++it;
  BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::UNREGISTER);
  BOOST_CHECK_EQUAL(it->getName(), "/a/b");
  BOOST_CHECK_EQUAL(it->getRoute(), routeUnregister);

  ++it;
  BOOST_CHECK(it == batch.end());
}


BOOST_AUTO_TEST_SUITE_END()

} // namespace tests
} // namespace rib
} // namespace nfd
