/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012 University of California, Los Angeles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
 *         卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
 *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 */

#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp> 
using boost::test_tools::output_test_stream;

#include <boost/make_shared.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

#include "../model/sync-std-name-info.h"
#include "../model/sync-full-state.h"
#include "../model/sync-diff-state.h"

using namespace Sync;
using namespace std;
using namespace boost;

BOOST_AUTO_TEST_SUITE(StateTestSuite)

BOOST_AUTO_TEST_CASE (FullStateTest)
{
  BOOST_CHECK_NO_THROW (FullState ());
  FullState state;
  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 0);

  output_test_stream output;
  output << state.getTimeFromLastUpdate ();
  BOOST_CHECK (output.is_equal ("not-a-date-time", true));

  NameInfoConstPtr name = StdNameInfo::FindOrCreate ("/test/name");
  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 1);
  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 12);

  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (13)));
  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 13);

  BOOST_CHECK_NO_THROW (state.remove (name));
  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 0);

  BOOST_CHECK_EQUAL (state.getTimeFromLastUpdate ().total_milliseconds (), 0);
}

BOOST_AUTO_TEST_CASE (DiffStateTest)
{
  BOOST_CHECK_NO_THROW (DiffState ());
  DiffState state;
  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 0);

  NameInfoConstPtr name = StdNameInfo::FindOrCreate ("/test/name");
  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (12)));
  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 1);
  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 12);

  BOOST_CHECK_NO_THROW (state.update (name, SeqNo (13)));
  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 13);

  BOOST_CHECK_NO_THROW (state.remove (name));
  BOOST_CHECK_EQUAL (state.getLeaves ().size (), 1);
  BOOST_CHECK_EQUAL ((*state.getLeaves ().begin ())->getSeq ().getSeq (), 0);
}

BOOST_AUTO_TEST_SUITE_END()
