face: avoid multiple onFail events

refs #1497

Change-Id: I8fda3fea5cd8a314b30eef45da104109e9748afc
diff --git a/tests/daemon/face/dummy-face.hpp b/tests/daemon/face/dummy-face.hpp
index 7039286..ca45722 100644
--- a/tests/daemon/face/dummy-face.hpp
+++ b/tests/daemon/face/dummy-face.hpp
@@ -1,11 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  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
+ * Copyright (c) 2014,  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.
@@ -20,10 +21,10 @@
  *
  * 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/>.
- **/
+ */
 
-#ifndef NFD_TESTS_NFD_FACE_DUMMY_FACE_HPP
-#define NFD_TESTS_NFD_FACE_DUMMY_FACE_HPP
+#ifndef NFD_TESTS_DAEMON_FACE_DUMMY_FACE_HPP
+#define NFD_TESTS_DAEMON_FACE_DUMMY_FACE_HPP
 
 #include "face/face.hpp"
 #include "face/local-face.hpp"
@@ -90,4 +91,4 @@
 } // namespace tests
 } // namespace nfd
 
-#endif // NFD_TESTS_NFD_FACE_DUMMY_FACE_HPP
+#endif // NFD_TESTS_DAEMON_FACE_DUMMY_FACE_HPP
diff --git a/tests/daemon/face/face.cpp b/tests/daemon/face/face.cpp
index 46c0345..b82e0fa 100644
--- a/tests/daemon/face/face.cpp
+++ b/tests/daemon/face/face.cpp
@@ -1,11 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  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
+ * Copyright (c) 2014,  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.
@@ -68,6 +69,43 @@
   BOOST_CHECK_EQUAL(counters.getNOutDatas()    , 0);
 }
 
+class FaceFailTestFace : public DummyFace
+{
+public:
+  FaceFailTestFace()
+    : failCount(0)
+  {
+    this->onFail += bind(&FaceFailTestFace::failHandler, this, _1);
+  }
+
+  void
+  failOnce()
+  {
+    this->fail("reason");
+  }
+
+private:
+  void
+  failHandler(const std::string& reason)
+  {
+    BOOST_CHECK_EQUAL(reason, "reason");
+    ++this->failCount;
+  }
+
+public:
+  int failCount;
+};
+
+BOOST_AUTO_TEST_CASE(FailTwice)
+{
+  FaceFailTestFace face;
+  BOOST_CHECK_EQUAL(face.failCount, 0);
+  face.failOnce();
+  BOOST_CHECK_EQUAL(face.failCount, 1);
+  face.failOnce();
+  BOOST_CHECK_EQUAL(face.failCount, 1);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests