/*
* Author:          Patrick-Christopher Mattulat
* Co-Author:       Claude Sonnet 4.6 (LLM)
* Company:         Lynar Studios
* E-Mail:          webmaster@lynarstudios.com
* Created:         2023-02-21
* Changed:         2026-06-23
*
* */

#include <classes/TestHelper.hpp>
#include <gtest/gtest.h>
#include <ls-std/ls-std-core.hpp>
#include <ls-std/ls-std-io.hpp>
#include <string>

using ls::standard::io::SectionPairDocument;
using ls::standard::io::SectionPairFileReader;
using ls::standard::io::SectionPairFileReaderParameter;
using ls::standard::test::TestHelper;
using std::make_shared;
using std::shared_ptr;
using std::string;
using testing::Test;

namespace
{
  class SectionPairFileReaderIT : public Test
  {
    public:

      SectionPairFileReaderIT() = default;
      ~SectionPairFileReaderIT() override = default;

      static string getSectionPairFileLocation()
      {
        return TestHelper::getResourcesFolderLocation() + "server-settings-unix.txt";
      }
  };

  TEST_F(SectionPairFileReaderIT, read)
  {
    SectionPairFileReaderParameter parameter{};
    const auto document = make_shared<SectionPairDocument>();
    parameter.setDocument(document);
    parameter.setFilePath(SectionPairFileReaderIT::getSectionPairFileLocation());
    SectionPairFileReader reader{parameter};
    reader.read();

    ASSERT_TRUE(!reader.getDocument()->getSectionList().empty());
    ASSERT_STREQ("general", reader.getDocument()->get(0)->getSectionId().c_str());
    ASSERT_EQ(2, reader.getDocument()->get(0)->getRowAmount());
  }
}
