//------------------------------------------------------------------------------
/*
    This file is part of clio: https://github.com/XRPLF/clio
    Copyright (c) 2023, the clio developers.

    Permission to use, copy, modify, and distribute this software for any
    purpose with or without fee is hereby granted, provided that the above
    copyright notice and this permission notice appear in all copies.

    THE  SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    WITH  REGARD  TO  THIS  SOFTWARE  INCLUDING  ALL  IMPLIED  WARRANTIES  OF
    MERCHANTABILITY  AND  FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    ANY  SPECIAL,  DIRECT,  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER  RESULTING  FROM  LOSS  OF USE, DATA OR PROFITS, WHETHER IN AN
    ACTION  OF  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================

#pragma once

#include "etl/NetworkValidatedLedgersInterface.hpp"

#include <boost/signals2/connection.hpp>
#include <gmock/gmock.h>

#include <cstdint>
#include <memory>
#include <optional>

struct MockNetworkValidatedLedgers : public etl::NetworkValidatedLedgersInterface {
    MOCK_METHOD(void, push, (uint32_t), (override));
    MOCK_METHOD(std::optional<uint32_t>, getMostRecent, (), (override));
    MOCK_METHOD(bool, waitUntilValidatedByNetwork, (uint32_t, std::optional<uint32_t>), (override));
    MOCK_METHOD(
        boost::signals2::scoped_connection,
        subscribe,
        (etl::NetworkValidatedLedgersInterface::SignalType::slot_type const& subscriber),
        (override)
    );
};

template <template <typename> typename MockType>
struct MockNetworkValidatedLedgersPtrImpl {
    std::shared_ptr<MockType<MockNetworkValidatedLedgers>> ptr =
        std::make_shared<MockType<MockNetworkValidatedLedgers>>();

    operator std::shared_ptr<etl::NetworkValidatedLedgersInterface>() const
    {
        return ptr;
    }

    MockType<MockNetworkValidatedLedgers>&
    operator*()
    {
        return *ptr;
    }
};

using MockNetworkValidatedLedgersPtr = MockNetworkValidatedLedgersPtrImpl<testing::NiceMock>;
using StrictMockNetworkValidatedLedgersPtr = MockNetworkValidatedLedgersPtrImpl<testing::StrictMock>;
