face: Refactored code to set interest filter

Change-Id: I1f9637a79c03a9e24608403d963bbfc4d9bcab1c
diff --git a/tests/management/test-ndnd-forwarding-entry.cpp b/tests/management/test-ndnd-forwarding-entry.cpp
new file mode 100644
index 0000000..bd5aa9f
--- /dev/null
+++ b/tests/management/test-ndnd-forwarding-entry.cpp
@@ -0,0 +1,59 @@
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include "management/ndnd-forwarding-entry.hpp"
+
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+#endif
+
+#include <fstream>
+#include <boost/test/output_test_stream.hpp>
+
+using namespace std;
+namespace ndn {
+namespace ndnd {
+
+const uint8_t FORWARDING_ENTRY[] = {0x81, 0x19, 0x83, 0x07, 0x73, 0x65, 0x6c, 0x66, 0x72, 0x65, 0x67, 0x03, 0x0b, 0x04, 0x01, 0x61, 0x04, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x8a, 0x01, 0x03};
+
+BOOST_AUTO_TEST_SUITE(TestForwardingEntry)
+
+BOOST_AUTO_TEST_CASE (Encode)
+{
+  ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), -1);
+  const Block &wire = forwardingEntry.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE (Decode)
+{
+  ForwardingEntry forwardingEntry;
+  
+  BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, sizeof(FORWARDING_ENTRY))));
+
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg");
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getPrefix(), Name("/a/prefix"));
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getFaceId(), -1);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getActive(), true);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getChildInherit(), true);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getAdvertise(), false);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLast(), false);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCapture(), false);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), -1);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndnd
+} // namespace ndn
diff --git a/tests/management/test-nfd-control.cpp b/tests/management/test-nfd-control.cpp
new file mode 100644
index 0000000..48295aa
--- /dev/null
+++ b/tests/management/test-nfd-control.cpp
@@ -0,0 +1,108 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "management/control-response.hpp"
+#include "management/fib-management-options.hpp"
+
+#include <boost/test/unit_test.hpp>
+#include <boost/test/output_test_stream.hpp>
+
+using namespace std;
+
+namespace ndn {
+
+BOOST_AUTO_TEST_SUITE(TestNfdControl)
+
+const uint8_t TestControlResponse[] = {0x65, 0x17, 0x66, 0x02, 0x01, 0x94, 0x67, 0x11, 0x4e, 0x6f, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64};
+
+const uint8_t TestFibManagementOptions[] = {
+  0x68, 0x1e, 0x03, 0x16, 0x04, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68,
+  0x6f, 0x73, 0x74, 0x04, 0x03, 0x72, 0x65, 0x67, 0x04, 0x04, 0x74, 0x65,
+  0x73, 0x74, 0x69, 0x01, 0x00, 0x6a, 0x01, 0x00
+};
+
+// ControlResponse
+
+BOOST_AUTO_TEST_CASE (ControlResponseEncode)
+{
+  ndn::ControlResponse controlResponse(404, "Nothing not found");
+  const Block &wire = controlResponse.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(TestControlResponse, TestControlResponse+sizeof(TestControlResponse),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE (ControlResponseDecode)
+{
+  ndn::ControlResponse controlResponse;
+  
+  BOOST_REQUIRE_NO_THROW(controlResponse.wireDecode(Block(TestControlResponse, sizeof(TestControlResponse))));
+
+  BOOST_REQUIRE_EQUAL(controlResponse.getCode(), 404);
+  BOOST_REQUIRE_EQUAL(controlResponse.getText(), "Nothing not found");
+}
+
+// FibManagementOptions
+
+BOOST_AUTO_TEST_CASE (FibManagementOptionsEncoding)
+{
+  Name n ("/localhost/reg/test");
+  FibManagementOptions opt;
+
+  opt.setName (n);
+  opt.setFaceId (0);
+  opt.setCost (0);
+
+  const ndn::Block& blk = opt.wireEncode ();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS (TestFibManagementOptions,
+                                   TestFibManagementOptions + sizeof (TestFibManagementOptions),
+                                   blk.begin (), blk.end ());
+}
+
+BOOST_AUTO_TEST_CASE (FibManagementOptionsFastEncoding)
+{
+  Name n ("/localhost/reg/test");
+  FibManagementOptions opt;
+
+  opt.setName (n);
+  opt.setFaceId (0);
+  opt.setCost (0);
+
+  EncodingBuffer blk;
+
+  BOOST_REQUIRE_NO_THROW (opt.wireEncode (blk));
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS (TestFibManagementOptions,
+                                   TestFibManagementOptions + sizeof (TestFibManagementOptions),
+                                   blk.begin (), blk.end ());
+
+  EncodingBuffer blk2 (4);
+
+  BOOST_REQUIRE_NO_THROW (opt.wireEncode (blk2));
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS (TestFibManagementOptions,
+                                   TestFibManagementOptions + sizeof (TestFibManagementOptions),
+                                   blk2.begin (), blk2.end ());
+}
+
+BOOST_AUTO_TEST_CASE (FibManagementOptionsDecoding)
+{
+  Block blk (TestFibManagementOptions, sizeof (TestFibManagementOptions));
+  Name n ("/localhost/reg/test");
+  FibManagementOptions opt;
+
+  BOOST_REQUIRE_NO_THROW (opt.wireDecode (blk));
+  
+  BOOST_CHECK_EQUAL (opt.getName (), n);
+  BOOST_CHECK_EQUAL (opt.getFaceId (), 0);
+  BOOST_CHECK_EQUAL (opt.getCost (), 0);
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn