tools: nfdc creates Face and KeyChain in main function

refs #3749

Change-Id: I169ad766634371b0192ebae640355298b78aaaa4
diff --git a/tests/tools/nfdc/command-parser.t.cpp b/tests/tools/nfdc/command-parser.t.cpp
index 435392d..73ad3cc 100644
--- a/tests/tools/nfdc/command-parser.t.cpp
+++ b/tests/tools/nfdc/command-parser.t.cpp
@@ -40,72 +40,62 @@
 BOOST_AUTO_TEST_CASE(Basic)
 {
   CommandParser parser;
-
-  std::string lastName;
-  auto makeExecute = [&] (const std::string& name) {
-    return [&, name] (const CommandArguments& args) {
-      lastName = name;
-    };
-  };
+  ExecuteCommand dummyExecute = [] (ExecuteContext&) { return 0; };
 
   CommandDefinition defHelp("help", "");
   defHelp
     .addArg("noun", ArgValueType::STRING, Required::NO, Positional::YES)
     .addArg("verb", ArgValueType::STRING, Required::NO, Positional::YES);
-  parser.addCommand(defHelp, makeExecute("help"), AVAILABLE_IN_ONE_SHOT);
+  parser.addCommand(defHelp, dummyExecute, AVAILABLE_IN_ONE_SHOT);
 
   CommandDefinition defStatusShow("status", "show");
-  parser.addCommand(defStatusShow, makeExecute("status show"));
+  parser.addCommand(defStatusShow, dummyExecute);
   parser.addAlias("status", "show", "list");
   BOOST_CHECK_THROW(parser.addAlias("status", "show2", "list"), std::out_of_range);
 
   CommandDefinition defRouteList("route", "list");
   defRouteList
     .addArg("nexthop", ArgValueType::FACE_ID_OR_URI, Required::NO, Positional::YES);
-  parser.addCommand(defRouteList, makeExecute("route list"));
+  parser.addCommand(defRouteList, dummyExecute);
 
   CommandDefinition defRouteAdd("route", "add");
   defRouteAdd
     .addArg("prefix", ArgValueType::NAME, Required::YES, Positional::YES)
     .addArg("nexthop", ArgValueType::FACE_ID_OR_URI, Required::YES, Positional::YES);
-  parser.addCommand(defRouteAdd, makeExecute("route add"));
+  parser.addCommand(defRouteAdd, dummyExecute);
   parser.addAlias("route", "add", "add2");
 
 
-  CommandParser::Execute* execute = nullptr;
+  std::string noun, verb;
   CommandArguments ca;
+  ExecuteCommand execute;
 
-  std::tie(execute, ca) = parser.parse(std::vector<std::string>{"help"},
-                                       ParseMode::ONE_SHOT);
-  BOOST_REQUIRE(execute != nullptr);
-  (*execute)(ca);
-  BOOST_CHECK_EQUAL(lastName, "help");
+  std::tie(noun, verb, ca, execute) = parser.parse(
+    std::vector<std::string>{"help"}, ParseMode::ONE_SHOT);
+  BOOST_CHECK_EQUAL(noun, "help");
+  BOOST_CHECK_EQUAL(verb, "");
 
-  std::tie(execute, ca) = parser.parse(std::vector<std::string>{"status"},
-                                       ParseMode::ONE_SHOT);
-  BOOST_REQUIRE(execute != nullptr);
-  (*execute)(ca);
-  BOOST_CHECK_EQUAL(lastName, "status show");
+  std::tie(noun, verb, ca, execute) = parser.parse(
+    std::vector<std::string>{"status"}, ParseMode::ONE_SHOT);
+  BOOST_CHECK_EQUAL(noun, "status");
+  BOOST_CHECK_EQUAL(verb, "show");
 
-  std::tie(execute, ca) = parser.parse(std::vector<std::string>{"route", "add", "/n", "300"},
-                                       ParseMode::ONE_SHOT);
-  BOOST_REQUIRE(execute != nullptr);
-  (*execute)(ca);
-  BOOST_CHECK_EQUAL(lastName, "route add");
+  std::tie(noun, verb, ca, execute) = parser.parse(
+    std::vector<std::string>{"route", "add", "/n", "300"}, ParseMode::ONE_SHOT);
+  BOOST_CHECK_EQUAL(noun, "route");
+  BOOST_CHECK_EQUAL(verb, "add");
   BOOST_CHECK_EQUAL(boost::any_cast<Name>(ca.at("prefix")), "/n");
   BOOST_CHECK_EQUAL(boost::any_cast<uint64_t>(ca.at("nexthop")), 300);
 
-  std::tie(execute, ca) = parser.parse(std::vector<std::string>{"route", "add2", "/n", "300"},
-                                       ParseMode::ONE_SHOT);
-  BOOST_REQUIRE(execute != nullptr);
-  (*execute)(ca);
-  BOOST_CHECK_EQUAL(lastName, "route add");
+  std::tie(noun, verb, ca, execute) = parser.parse(
+    std::vector<std::string>{"route", "add2", "/n", "300"}, ParseMode::ONE_SHOT);
+  BOOST_CHECK_EQUAL(noun, "route");
+  BOOST_CHECK_EQUAL(verb, "add");
 
-  std::tie(execute, ca) = parser.parse(std::vector<std::string>{"route", "list", "400"},
-                                       ParseMode::ONE_SHOT);
-  BOOST_REQUIRE(execute != nullptr);
-  (*execute)(ca);
-  BOOST_CHECK_EQUAL(lastName, "route list");
+  std::tie(noun, verb, ca, execute) = parser.parse(
+    std::vector<std::string>{"route", "list", "400"}, ParseMode::ONE_SHOT);
+  BOOST_CHECK_EQUAL(noun, "route");
+  BOOST_CHECK_EQUAL(verb, "list");
   BOOST_CHECK_EQUAL(boost::any_cast<uint64_t>(ca.at("nexthop")), 400);
 
   BOOST_CHECK_THROW(parser.parse(std::vector<std::string>{}, ParseMode::ONE_SHOT),
@@ -120,7 +110,7 @@
                     CommandDefinition::Error);
 }
 
-BOOST_AUTO_TEST_SUITE_END() // TestCommandDefinition
+BOOST_AUTO_TEST_SUITE_END() // TestCommandParser
 BOOST_AUTO_TEST_SUITE_END() // Nfdc
 
 } // namespace tests