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

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <ls-std-time-test.hpp>
#include <ls-std/ls-std-core.hpp>
#include <ls-std/ls-std-time.hpp>
#include <memory>

using ls::standard::core::IllegalArgumentException;
using ls::standard::time::DateParameter;
using ls::standard::time::SystemTime;
using ls::standard::time::SystemTimeParameter;
using std::make_shared;
using std::shared_ptr;
using test::time::MockClock;
using testing::AtLeast;
using testing::Return;
using testing::Test;

namespace
{
  class SystemTimeTest : public Test
  {
    public:

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

  TEST_F(SystemTimeTest, constructor)
  {
    EXPECT_THROW(
        {
          try
          {
            SystemTime systemTime{nullptr};
          }
          catch (const IllegalArgumentException &_exception)
          {
            throw;
          }
        },
        IllegalArgumentException);
  }

  TEST_F(SystemTimeTest, getClassName)
  {
    ASSERT_STREQ("SystemTime", SystemTime{}.getClassName().c_str());
  }

  TEST_F(SystemTimeTest, setTime)
  {
    const auto parameter = make_shared<SystemTimeParameter>();
    const auto posixClock = make_shared<MockClock>();
    parameter->setClock(posixClock);
    const auto birthday = DateParameter(1990, 10, 26, 11, 25, 00);

    EXPECT_CALL(*posixClock, setTime(birthday)).Times(AtLeast(1));
    ON_CALL(*posixClock, setTime(birthday)).WillByDefault(Return(true));

    ASSERT_TRUE(SystemTime{parameter}.set(birthday));
  }
}
