
#include "SimCore/Identifier.hpp"
#include "SimCore/IdentifierMaker.hpp"
#include "SimCore/Messages/GroundThruthTrack.hpp"
#include "SimCore/Messages/SensorTrack.hpp"
#include "SimCore/Messages/Track.hpp"
#include "SimCore/SimCore.hpp"
#include "WHISPER/Messages/Message.hpp"
#include <list>
#include <memory>
#include <string>
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <SimCore/Messages/RadarTrack.hpp>
#include <loguru.hpp>





SCENARIO("Testing the SimCore Track")
{
  GIVEN("different Attributes for a Track in different forms")
  {
    
    std::vector<std::shared_ptr<SimCore::Track>> trackstore;
    
    SimCore::Identifier parentID(0,1,false);

    
    SimCore::IdentifierMaker IDMaker;
    auto ID1 = IDMaker.getNewIdentifier(1, SimCore::ObjectSource::INTERNAL);
    auto ID2 = IDMaker.getNewIdentifier(1, SimCore::ObjectSource::INTERNAL);

    auto track = std::make_shared<SimCore::RadarTrack>(WHISPER::SourceType::SENSOR,*ID1.get());
    track->setSpeed(100);

    trackstore.push_back(track);

    auto track2 = std::make_shared<SimCore::GroundTruthTrack>(WHISPER::SourceType::SENSOR,*ID2,SimCore::TrackKind::OWN_TRACK);
    track2->setSpeed(50);
    trackstore.push_back(track2);
    
    auto receivedTrack1 = trackstore[0];
    auto receivedTrack2 = trackstore[1];


    WHEN("constructing Track Object with data")
    {
    //    auto rev = list.front();
    //    LOG_S(INFO)<<rev->msgType_;
    // //   auto track2 = dynamic_pointer_cast<SimCore::RadarTrack>(rev);


      THEN("check if Track attributes are correct")
      {
        REQUIRE(trackstore.size() == 2);

        REQUIRE(receivedTrack1->getTrackkind() == SimCore::TrackKind::RADAR_TRACK);

        if (receivedTrack1->getTrackkind() == SimCore::TrackKind::RADAR_TRACK) {
            auto radarTrackRecv1 = std::dynamic_pointer_cast<SimCore::RadarTrack>(receivedTrack1);
            REQUIRE(radarTrackRecv1->getSpeed() == 100);

        }

        REQUIRE(receivedTrack2->getTrackkind() == SimCore::TrackKind::OWN_TRACK);
        // REQUIRE(track12->getSpeed() == 100);






      } //THEN
    } // WHEN
  } // GIVEN
} //SCENARIO