saving from a test works

This commit is contained in:
David Markowitz
2024-06-04 14:44:51 -07:00
parent af651f0d63
commit 91ec214eea
14 changed files with 1830 additions and 3 deletions

View File

@@ -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)

View 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();
}

View 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)

File diff suppressed because it is too large Load Diff