tests: register instead of install DummyStrategy

refs #3868

Change-Id: I5e44582625be51ef874e2a92e4bb7cc22d5b607b
diff --git a/tests/daemon/fw/dummy-strategy.hpp b/tests/daemon/fw/dummy-strategy.hpp
index a6af8ac..6d4d45d 100644
--- a/tests/daemon/fw/dummy-strategy.hpp
+++ b/tests/daemon/fw/dummy-strategy.hpp
@@ -33,28 +33,27 @@
 
 /** \brief strategy for unit testing
  *
- *  Unless otherwise indicated, triggers are recorded but does nothing.
+ *  Triggers are recorded but do nothing.
+ *
+ *  DummyStrategy registers itself as /dummy-strategy/<max-version>, so that it can be instantiated
+ *  with any version number. Aliases can be created with \p registerAs function.
  */
 class DummyStrategy : public fw::Strategy
 {
 public:
   static void
-  registerAs(const Name& name)
-  {
-    if (!fw::Strategy::canCreate(name)) {
-      fw::Strategy::registerType<DummyStrategy>(name);
-    }
-  }
+  registerAs(const Name& strategyName);
 
-  DummyStrategy(Forwarder& forwarder, const Name& name)
-    : Strategy(forwarder)
-    , afterReceiveInterest_count(0)
-    , beforeSatisfyInterest_count(0)
-    , beforeExpirePendingInterest_count(0)
-    , afterReceiveNack_count(0)
-  {
-    this->setInstanceName(name);
-  }
+  static Name
+  getStrategyName(uint64_t version = std::numeric_limits<uint64_t>::max());
+
+  /** \brief constructor
+   *
+   *  \p name is recorded unchanged as \p getInstanceName() , and will not automatically
+   *  gain a version number when instantiated without a version number.
+   */
+  explicit
+  DummyStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
 
   /** \brief after receive Interest trigger
    *
@@ -63,36 +62,30 @@
    */
   void
   afterReceiveInterest(const Face& inFace, const Interest& interest,
-                       const shared_ptr<pit::Entry>& pitEntry) override
-  {
-    ++afterReceiveInterest_count;
-
-    if (interestOutFace != nullptr) {
-      this->sendInterest(pitEntry, *interestOutFace, interest);
-    }
-    else {
-      this->rejectPendingInterest(pitEntry);
-    }
-  }
+                       const shared_ptr<pit::Entry>& pitEntry) override;
 
   void
   beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
-                        const Face& inFace, const Data& data) override
-  {
-    ++beforeSatisfyInterest_count;
-  }
+                        const Face& inFace, const Data& data) override;
 
   void
-  beforeExpirePendingInterest(const shared_ptr<pit::Entry>& pitEntry) override
-  {
-    ++beforeExpirePendingInterest_count;
-  }
+  beforeExpirePendingInterest(const shared_ptr<pit::Entry>& pitEntry) override;
 
   void
   afterReceiveNack(const Face& inFace, const lp::Nack& nack,
-                   const shared_ptr<pit::Entry>& pitEntry) override
+                   const shared_ptr<pit::Entry>& pitEntry) override;
+
+protected:
+  /** \brief register an alias
+   *  \tparam S subclass of DummyStrategy
+   */
+  template<typename S>
+  static void
+  registerAsImpl(const Name& strategyName)
   {
-    ++afterReceiveNack_count;
+    if (!fw::Strategy::canCreate(strategyName)) {
+      fw::Strategy::registerType<S>(strategyName);
+    }
   }
 
 public: