mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-25 16:58:08 +00:00
saving from a test works
This commit is contained in:
@@ -9,6 +9,7 @@ add_subdirectory(dGameMessagesTests)
|
||||
list(APPEND DGAMETEST_SOURCES ${DGAMEMESSAGES_TESTS})
|
||||
|
||||
file(COPY ${GAMEMESSAGE_TESTBITSTREAMS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
file(COPY ${COMPONENT_TEST_DATA} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Add the executable. Remember to add all tests above this!
|
||||
add_executable(dGameTests ${DGAMETEST_SOURCES})
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "EntityInfo.h"
|
||||
#include "EntityManager.h"
|
||||
#include "dConfig.h"
|
||||
#include "dZoneManager.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class dZoneManager;
|
||||
@@ -34,6 +35,8 @@ protected:
|
||||
Game::server = new dServerMock();
|
||||
Game::config = new dConfig("worldconfig.ini");
|
||||
Game::entityManager = new EntityManager();
|
||||
Game::zoneManager = new dZoneManager();
|
||||
Game::zoneManager->LoadZone(LWOZONEID(1, 0, 0));
|
||||
|
||||
// Create a CDClientManager instance and load from defaults
|
||||
CDClientManager::LoadValuesFromDefaults();
|
||||
@@ -42,6 +45,7 @@ protected:
|
||||
void TearDownDependencies() {
|
||||
if (Game::server) delete Game::server;
|
||||
if (Game::entityManager) delete Game::entityManager;
|
||||
if (Game::zoneManager) delete Game::zoneManager;
|
||||
if (Game::logger) {
|
||||
Game::logger->Flush();
|
||||
delete Game::logger;
|
||||
|
||||
@@ -2,6 +2,7 @@ set(DCOMPONENTS_TESTS
|
||||
"DestroyableComponentTests.cpp"
|
||||
"PetComponentTests.cpp"
|
||||
"SimplePhysicsComponentTests.cpp"
|
||||
"SavingTests.cpp"
|
||||
)
|
||||
|
||||
# Get the folder name and prepend it to the files above
|
||||
@@ -10,3 +11,8 @@ list(TRANSFORM DCOMPONENTS_TESTS PREPEND "${thisFolderName}/")
|
||||
|
||||
# Export to parent scope
|
||||
set(DCOMPONENTS_TESTS ${DCOMPONENTS_TESTS} PARENT_SCOPE)
|
||||
|
||||
# Copy test files to testing directory
|
||||
add_subdirectory(TestData)
|
||||
list(TRANSFORM COMPONENT_TEST_DATA PREPEND "${thisFolderName}/")
|
||||
set(COMPONENT_TEST_DATA ${COMPONENT_TEST_DATA} PARENT_SCOPE)
|
||||
|
||||
31
tests/dGameTests/dComponentsTests/SavingTests.cpp
Normal file
31
tests/dGameTests/dComponentsTests/SavingTests.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "GameDependencies.h"
|
||||
#include "Character.h"
|
||||
#include "Entity.h"
|
||||
#include "tinyxml2.h"
|
||||
|
||||
class SavingTest : public GameDependenciesTest {
|
||||
protected:
|
||||
std::unique_ptr<Entity> entity;
|
||||
std::unique_ptr<Character> character;
|
||||
tinyxml2::XMLDocument doc;
|
||||
void SetUp() override {
|
||||
SetUpDependencies();
|
||||
entity = std::make_unique<Entity>(1, GameDependenciesTest::info);
|
||||
character = std::make_unique<Character>(1, nullptr);
|
||||
doc.LoadFile("./test_xml_data.xml");
|
||||
entity->SetCharacter(character.get());
|
||||
character->_setXmlDoc(doc);
|
||||
character->SetEntity(entity.get());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
entity->SetCharacter(nullptr);
|
||||
entity.reset();
|
||||
character.reset();
|
||||
TearDownDependencies();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SavingTest, EntityLevelTest) {
|
||||
character->SaveXMLToDatabase();
|
||||
}
|
||||
10
tests/dGameTests/dComponentsTests/TestData/CMakeLists.txt
Normal file
10
tests/dGameTests/dComponentsTests/TestData/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
set(COMPONENT_TEST_DATA
|
||||
"test_xml_data.xml"
|
||||
)
|
||||
|
||||
# Get the folder name and prepend it to the files above
|
||||
get_filename_component(thisFolderName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
list(TRANSFORM COMPONENT_TEST_DATA PREPEND "${thisFolderName}/")
|
||||
|
||||
# Export our list of files
|
||||
set(COMPONENT_TEST_DATA ${COMPONENT_TEST_DATA} PARENT_SCOPE)
|
||||
1374
tests/dGameTests/dComponentsTests/TestData/test_xml_data.xml
Normal file
1374
tests/dGameTests/dComponentsTests/TestData/test_xml_data.xml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user