TestDataFactory.cpp 2.5 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: 2022-05-11
  7. *
  8. * */
  9. #include "TestDataFactory.hpp"
  10. ls::std::logic::StateMachine ls_std_test::TestDataFactory::createStateMachine()
  11. {
  12. ls::std::logic::StateMachine stateMachine{"test_machine"};
  13. std::shared_ptr<ls::std::logic::State> stateA = std::make_shared<ls::std::logic::State>("A");
  14. std::shared_ptr<ls::std::logic::State> stateB = std::make_shared<ls::std::logic::State>("B");
  15. std::shared_ptr<ls::std::logic::State> stateC = std::make_shared<ls::std::logic::State>("C");
  16. std::shared_ptr<ls::std::logic::State> stateD = std::make_shared<ls::std::logic::State>("D");
  17. std::shared_ptr<ls::std::logic::State> stateE = std::make_shared<ls::std::logic::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::io::XmlNode> ls_std_test::TestDataFactory::createXmlContent()
  34. {
  35. std::shared_ptr<ls::std::io::XmlNode> root = std::make_shared<ls::std::io::XmlNode>("dialog");
  36. std::shared_ptr<ls::std::io::XmlAttribute> attribute{};
  37. std::shared_ptr<ls::std::io::XmlNode> child{};
  38. std::shared_ptr<ls::std::io::XmlNode> text{};
  39. attribute = std::make_shared<ls::std::io::XmlAttribute>("name");
  40. attribute->setValue("dungeon_001");
  41. root->addAttributeToEnd(attribute);
  42. child = std::make_shared<ls::std::io::XmlNode>("dialogUnit");
  43. attribute = std::make_shared<ls::std::io::XmlAttribute>("id");
  44. attribute->setValue("001");
  45. child->addAttributeToEnd(attribute);
  46. text = std::make_shared<ls::std::io::XmlNode>("text");
  47. text->setValue("Hello!");
  48. child->addChildToEnd(text);
  49. root->addChildToEnd(child);
  50. child = std::make_shared<ls::std::io::XmlNode>("dialogUnit");
  51. attribute = std::make_shared<ls::std::io::XmlAttribute>("id");
  52. attribute->setValue("002");
  53. child->addAttributeToEnd(attribute);
  54. text = std::make_shared<ls::std::io::XmlNode>("text");
  55. text->setValue("Hello again!");
  56. child->addChildToEnd(text);
  57. root->addChildToEnd(child);
  58. return root;
  59. }