Skip to content
Snippets Groups Projects
Verified Commit 6ade42a2 authored by Martin Stump's avatar Martin Stump
Browse files

Add MockEntityRepository and EntityRepositoryTest


Signed-off-by: default avatarMartin Stump <martin.stump@mercedes-benz.com>
parent 0204f627
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
################################################################################
add_executable(TrafficTest)
target_sources(TrafficTest PUBLIC entity_test.cc)
target_sources(TrafficTest PUBLIC entity_repository_test.cc entity_test.cc)
target_include_directories(TrafficTest PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/test>)
target_link_libraries(TrafficTest PUBLIC MantleAPI::MantleAPI GTest::gmock_main)
......
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "MantleAPI/Traffic/mock_entity_repository.h"
namespace
{
using testing::_;
using testing::An;
using testing::Const;
using testing::Return;
class EntityRepositoryTest : public testing::Test
{
protected:
mantle_api::MockEntityRepository mock_entity_repository_;
mantle_api::IEntityRepository& entity_repository_{mock_entity_repository_};
};
TEST_F(EntityRepositoryTest, DISABLED_CreateVehicle) // FIXME: Missing MockVehicle
{
// const auto mock_vehicle = mantle_api::MockVehicle{};
// DefaultValue<mantle_api::IVehicle&>::Set(mock_vehicle);
EXPECT_CALL(mock_entity_repository_, Create(_, An<const mantle_api::VehicleProperties&>())).Times(1);
entity_repository_.Create({}, mantle_api::VehicleProperties{});
}
} // namespace
/*******************************************************************************
* Copyright (c) 2023, Mercedes-Benz Tech Innovation GmbH
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#pragma once
#include <gmock/gmock.h>
#include "MantleAPI/Traffic/i_entity_repository.h"
namespace mantle_api
{
class MockEntityRepository : public IEntityRepository
{
public:
MOCK_METHOD(IVehicle&, Create, (const std::string& name, const VehicleProperties& properties), (override));
MOCK_METHOD(IVehicle&, Create, (UniqueId id, const std::string& name, const VehicleProperties& properties), (override));
MOCK_METHOD(IPedestrian&, Create, (const std::string& name, const PedestrianProperties& properties), (override));
MOCK_METHOD(IPedestrian&, Create, (UniqueId id, const std::string& name, const PedestrianProperties& properties), (override));
MOCK_METHOD(IStaticObject&, Create, (const std::string& name, const mantle_api::StaticObjectProperties& properties), (override));
MOCK_METHOD(IStaticObject&, Create, (UniqueId id, const std::string& name, const StaticObjectProperties& properties), (override));
MOCK_METHOD(IVehicle&, GetHost, (), (override));
MOCK_METHOD(std::optional<std::reference_wrapper<IEntity>>, Get, (const std::string& name), (override));
MOCK_METHOD(std::optional<std::reference_wrapper<const IEntity>>, Get, (const std::string& name), (const, override));
MOCK_METHOD(std::optional<std::reference_wrapper<IEntity>>, Get, (UniqueId id), (override));
MOCK_METHOD(std::optional<std::reference_wrapper<const IEntity>>, Get, (UniqueId id), (const, override));
MOCK_METHOD(bool, Contains, (UniqueId id), (const, override));
MOCK_METHOD(void, Delete, (const std::string& name), (override));
MOCK_METHOD(void, Delete, (UniqueId id), (override));
MOCK_METHOD(const std::vector<std::unique_ptr<mantle_api::IEntity>>&, GetEntities, (), (const, override));
MOCK_METHOD(void, RegisterEntityCreatedCallback, (const std::function<void(IEntity&)>& callback), (override));
MOCK_METHOD(void, RegisterEntityDeletedCallback, (const std::function<void(const std::string&)>& callback), (override));
MOCK_METHOD(void, RegisterEntityDeletedCallback, (const std::function<void(UniqueId)>& callback), (override));
};
} // namespace mantle_api
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment