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

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

using ls::standard::core::IllegalArgumentException;
using ls::standard::io::SectionPairMessageFormatter;
using ls::standard::io::SectionPairRowSingleValueArgumentEvaluator;
using std::make_shared;
using std::shared_ptr;
using std::string;
using testing::Test;
using testing::TestWithParam;
using testing::Values;

namespace
{
  class SectionPairRowSingleValueArgumentEvaluatorTest : public Test
  {
    public:

      SectionPairRowSingleValueArgumentEvaluatorTest() = default;
      ~SectionPairRowSingleValueArgumentEvaluatorTest() override = default;
  };

  class SectionPairRowSingleValueArgumentEvaluatorTest_InvalidArgumentTest : public TestWithParam<string>
  {
    public:

      SectionPairRowSingleValueArgumentEvaluatorTest_InvalidArgumentTest() = default;
      ~SectionPairRowSingleValueArgumentEvaluatorTest_InvalidArgumentTest() override = default;
  };

  TEST_F(SectionPairRowSingleValueArgumentEvaluatorTest, getClassName)
  {
    const auto evaluator = make_shared<SectionPairRowSingleValueArgumentEvaluator>("color=blue");
    ASSERT_STREQ("SectionPairRowSingleValueArgumentEvaluator", evaluator->getClassName().c_str());
  }

  TEST_P(SectionPairRowSingleValueArgumentEvaluatorTest_InvalidArgumentTest, evaluate)
  {
    EXPECT_THROW(
        {
          try
          {
            SectionPairRowSingleValueArgumentEvaluator(GetParam()).evaluate();
          }
          catch (const IllegalArgumentException &_exception)
          {
            const string actual = _exception.what();
            const string expected = _exception.getName() + " thrown - \"" + GetParam() + "\" is not a valid section pair single value row!";

            ASSERT_STREQ(SectionPairMessageFormatter::getFormattedMessage(expected).c_str(), actual.c_str());
            throw;
          }
        },
        IllegalArgumentException);
  }

  INSTANTIATE_TEST_SUITE_P(InvalidArgumentTest, SectionPairRowSingleValueArgumentEvaluatorTest_InvalidArgumentTest, Values("favourite-color", "a value\n"));
}
