mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 02:04:04 +00:00
chore: Assorted pet improvements (#1402)
* Assorted pet improvements * remove unecessary include * updates to address some feedback * fixed database code for testing * Removed reference member (for now) * Removed cmake flag
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
#include "dServer.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "EntityInfo.h"
|
||||
#include "EntityManager.h"
|
||||
#include "dConfig.h"
|
||||
@@ -33,6 +34,9 @@ protected:
|
||||
Game::server = new dServerMock();
|
||||
Game::config = new dConfig("worldconfig.ini");
|
||||
Game::entityManager = new EntityManager();
|
||||
|
||||
// Create a CDClientManager instance and load from defaults
|
||||
CDClientManager::Instance().LoadValuesFromDefaults();
|
||||
}
|
||||
|
||||
void TearDownDependencies() {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
set(DCOMPONENTS_TESTS
|
||||
"DestroyableComponentTests.cpp"
|
||||
"PetComponentTests.cpp"
|
||||
"SimplePhysicsComponentTests.cpp"
|
||||
)
|
||||
|
||||
|
43
tests/dGameTests/dComponentsTests/PetComponentTests.cpp
Normal file
43
tests/dGameTests/dComponentsTests/PetComponentTests.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "GameDependencies.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "BitStream.h"
|
||||
#include "PetComponent.h"
|
||||
#include "Entity.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "ePetAbilityType.h"
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
class PetTest : public GameDependenciesTest {
|
||||
protected:
|
||||
Entity* baseEntity;
|
||||
PetComponent* petComponent;
|
||||
CBITSTREAM
|
||||
|
||||
void SetUp() override {
|
||||
SetUpDependencies();
|
||||
|
||||
// Set up entity and pet component
|
||||
baseEntity = new Entity(15, GameDependenciesTest::info);
|
||||
petComponent = baseEntity->AddComponent<PetComponent>(1);
|
||||
|
||||
// Initialize some values to be not default
|
||||
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete baseEntity;
|
||||
TearDownDependencies();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(PetTest, PlacementNewAddComponentTest) {
|
||||
// Test adding component
|
||||
ASSERT_NE(petComponent, nullptr);
|
||||
baseEntity->AddComponent<PetComponent>(1);
|
||||
ASSERT_NE(baseEntity->GetComponent<PetComponent>(), nullptr);
|
||||
|
||||
// Test getting initial status
|
||||
ASSERT_EQ(petComponent->GetParent()->GetObjectID(), 15);
|
||||
ASSERT_EQ(petComponent->GetAbility(), ePetAbilityType::Invalid);
|
||||
}
|
Reference in New Issue
Block a user