/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

/**
* @file
* @copyright 2022 MPLv2
*/

/**
* @defgroup tests
*/


#define CATCH_CONFIG_MAIN

#include <catch2/catch.hpp>

#include "WHISPER/InternalUDPService.hpp"
#include "WHISPER/Messages/Message.hpp"
#include "zmq.hpp"

#include <WHISPER/Messages/Join.hpp>
#include <WHISPER/Messages/Protos/message.pb.h>
#include <memory>

/**
* @brief brief test description
* @ingroup group
*/
SCENARIO("A test scenario","[keywords]")
{
  GIVEN("Preliminaries")
  {
    WHISPER::InternalUDPService service(0,1,WHISPER::SourceType::SIMCOMTROLER,8000,"127.0.0.255","127.0.0.1");
    auto receiver = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>();
    service.connect(receiver) ;
    // service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]);

    int i = 0;
    WHEN("doing something")
    { 
      
    LOG_S(INFO)<<"wating";
      // std::this_thread::sleep_for(std::chrono::milliseconds(1000));
      
      service.disconnect();
      
      LOG_S(INFO)<<"closing";
      THEN("expecting something to happen")
      {
      // service.unsubscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]);
        REQUIRE(receiver.unique() == true );
      } // THEN
    } // WHEN
  } // GIVEN
} // SCENARIO
