/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (C) 2014 Named Data Networking Project
 * See COPYING for copyright and distribution information.
 */

#ifndef NFD_TEST_FACE_DUMMY_FACE_HPP
#define NFD_TEST_FACE_DUMMY_FACE_HPP

#include "face/face.hpp"
#include "face/local-face.hpp"

namespace nfd {

/** \class DummyFace
 *  \brief a Face for unit testing
 */
template<class FaceBase>
class DummyFaceImpl : public FaceBase
{
public:
  virtual void
  sendInterest(const Interest& interest)
  {
    m_sentInterests.push_back(interest);
    this->afterSend();
  }

  virtual void
  sendData(const Data& data)
  {
    m_sentDatas.push_back(data);
    this->afterSend();
  }

  virtual void
  close()
  {
  }

  void
  receiveInterest(const Interest& interest)
  {
    this->onReceiveInterest(interest);
  }

  void
  receiveData(const Data& data)
  {
    this->onReceiveData(data);
  }

protected:
  virtual void
  afterSend()
  {
  }

public:
  std::vector<Interest> m_sentInterests;
  std::vector<Data> m_sentDatas;
};

typedef DummyFaceImpl<Face> DummyFace;
typedef DummyFaceImpl<LocalFace> DummyLocalFace;

} // namespace nfd

#endif // TEST_FACE_DUMMY_FACE_HPP
