testing works

This commit is contained in:
David Markowitz 2024-06-04 21:58:38 -07:00
parent 91ec214eea
commit bd0cafa33f
2 changed files with 23 additions and 1 deletions

View File

@ -460,6 +460,10 @@ public:
User* GetParentUser() const { return m_ParentUser; }
void _doQuickXMLDataParse() { DoQuickXMLDataParse(); }
void _setXmlData(const std::string& xmlData) { m_XMLData = xmlData; }
private:
void UpdateInfoFromDatabase();
/**

View File

@ -8,14 +8,21 @@ protected:
std::unique_ptr<Entity> entity;
std::unique_ptr<Character> character;
tinyxml2::XMLDocument doc;
tinyxml2::XMLPrinter printer{0, true, 0};
void SetUp() override {
SetUpDependencies();
Game::zoneManager->LoadZone(LWOZONEID(1800, 2, 0));
GameDependenciesTest::info.lot = 1;
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());
doc.Print(&printer);
character->_setXmlData(printer.CStr());
doc.Clear();
character->_doQuickXMLDataParse();
}
void TearDown() override {
@ -27,5 +34,16 @@ protected:
};
TEST_F(SavingTest, EntityLevelTest) {
doc.Print(&printer);
std::string xmlDataOriginal(printer.CStr());
doc.Clear();
character->SaveXMLToDatabase();
doc.Print(&printer);
std::string xmlDataModified(printer.CStr());
doc.Clear();
std::ofstream oldXml("./test_xml_data_original.xml");
std::ofstream newXml("./test_xml_data_new.xml");
oldXml << xmlDataOriginal;
newXml << xmlDataModified;
LOG("Component count: %i Same: %i", entity->GetComponents().size(), xmlDataOriginal == xmlDataModified);
}