TestDataFactory.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-16
  6. * Changed: 2021-04-23
  7. *
  8. * */
  9. #include "TestDataFactory.hpp"
  10. ls_std::StateMachine ls_std_test::TestDataFactory::createStateMachine()
  11. {
  12. ls_std::StateMachine stateMachine{"test_machine"};
  13. std::shared_ptr<ls_std::State> stateA = std::make_shared<ls_std::State>("A");
  14. std::shared_ptr<ls_std::State> stateB = std::make_shared<ls_std::State>("B");
  15. std::shared_ptr<ls_std::State> stateC = std::make_shared<ls_std::State>("C");
  16. std::shared_ptr<ls_std::State> stateD = std::make_shared<ls_std::State>("D");
  17. std::shared_ptr<ls_std::State> stateE = std::make_shared<ls_std::State>("E");
  18. // add states
  19. stateMachine.addState(stateA);
  20. stateMachine.addState(stateB);
  21. stateMachine.addState(stateC);
  22. stateMachine.addState(stateD);
  23. stateMachine.addState(stateE);
  24. // add connections / see state_machine_test.png
  25. stateA->addStateConnection("AB", stateB);
  26. stateB->addStateConnection("BC", stateC);
  27. stateB->addStateConnection("BD", stateD);
  28. stateC->addStateConnection("CB", stateB);
  29. stateC->addStateConnection("CE", stateE);
  30. stateD->addStateConnection("DE", stateE);
  31. return stateMachine;
  32. }
  33. std::shared_ptr<ls_std::XMLNode> ls_std_test::TestDataFactory::createXMLContent()
  34. {
  35. std::shared_ptr<ls_std::XMLNode> root = std::make_shared<ls_std::XMLNode>("dialog");
  36. std::shared_ptr<ls_std::XMLAttribute> attribute{};
  37. std::shared_ptr<ls_std::XMLNode> child{};
  38. std::shared_ptr<ls_std::XMLNode> text{};
  39. attribute = std::make_shared<ls_std::XMLAttribute>("name");
  40. attribute->setValue("dungeon_001");
  41. root->addAttributeToEnd(attribute);
  42. child = std::make_shared<ls_std::XMLNode>("dialogUnit");
  43. attribute = std::make_shared<ls_std::XMLAttribute>("id");
  44. attribute->setValue("001");
  45. child->addAttributeToEnd(attribute);
  46. text = std::make_shared<ls_std::XMLNode>("text");
  47. text->setValue("Hello!");
  48. child->addChildToEnd(text);
  49. root->addChildToEnd(child);
  50. child = std::make_shared<ls_std::XMLNode>("dialogUnit");
  51. attribute = std::make_shared<ls_std::XMLAttribute>("id");
  52. attribute->setValue("002");
  53. child->addAttributeToEnd(attribute);
  54. text = std::make_shared<ls_std::XMLNode>("text");
  55. text->setValue("Hello again!");
  56. child->addChildToEnd(text);
  57. root->addChildToEnd(child);
  58. return root;
  59. }