mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-27 15:10:16 +00:00
saving from a test works
This commit is contained in:
@@ -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