mod_SampleEntity.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include "stdafx.h"
  2. #include "mod_SampleEntity.h"
  3. #include "SpTest.h"
  4. // This code is generated by spgenex tool!
  5. RVC_TEST_CASE_METHOD(CSampleEntity, "TestForCSampleEntity")
  6. {
  7. Dbg("TestForCSampleEntity Debug.");
  8. return Error_Succeed;
  9. }
  10. RVC_TEST_CASE_METHOD(CSampleEntity, "TestForCSampleEntity2")
  11. {
  12. Dbg("TestForCSampleEntity2 Debug.");
  13. return Error_Succeed;
  14. }
  15. RVC_TEST_CASE("TestForCSampleEntity3")
  16. {
  17. CSampleEntity entity;
  18. Dbg("TestForCSampleEntity3 Debug: %s %s", entity.GetEntityName(), entity.GetEntityVersion());
  19. return Error_Unexpect;
  20. }
  21. RVC_TEST_CASE_VOID_CONTEXT(CSampleEntity, "SimpleContextTest") {
  22. SpReqAnsContext<SampleService_TwoWayFuncNotOverlap_Req, SampleService_TwoWayFuncNotOverlap_Ans>::Pointer ctx =
  23. new SpReqAnsContext<SampleService_TwoWayFuncNotOverlap_Req, SampleService_TwoWayFuncNotOverlap_Ans>(pTransactionContext);
  24. /** Set ctx->Req*/
  25. /*The aim function you would like test.*/
  26. if (Error_Succeed == TwoWayFuncNotOverlap(ctx)) {
  27. /** Check ctx->Ans' validty.*/
  28. /** Overwite the Result using pTransactionContext->SendAnswer()*/
  29. }
  30. }
  31. /** The aim test function must be member method of {entityClassName} and its signature should be like that
  32. ErrorCodeEnum --////teturn type must be ErrorCodeEnum
  33. {contextName} -- ////the function name is the same as the struct name generated by spgen tool.
  34. (SpReqAnsContext<{serviceName}_{contextName}_Req, serviceName}_{contextName}_Ans>::Pointer ctx)
  35. */
  36. RVC_TEST_CASE_CONTEXT_TWO_WAY(CSampleEntity, SampleService, TwoWayFuncOverlap, "TwoWayFuncOverlapName")
  37. {
  38. Req.req_context = "hello";
  39. TWO_WAY_CHECK_ANSWER_BEGIN(Ans)
  40. if (Ans.ans_context.Compare("world", true) != 0) {
  41. LOG_TRACE("Check failed, return except Error_Succeed");
  42. return Error_Unexpect;
  43. }
  44. Dbg("TwoWayFuncOverlap two way enter");
  45. return Error_Succeed;
  46. TWO_WAY_CHECK_ANSWER_END()
  47. }
  48. RVC_REGISTER_TEST_CASE_CONTEXT(CSampleEntity, SampleService, TwoWayFuncNormal, "TwoWayFuncNormal", "XXXXX")
  49. {
  50. Req.tbool = true;
  51. Req.tchar = 'I';
  52. Req.tint = 123;
  53. Req.tuint = 123;
  54. Req.tshort = 123;
  55. Req.tushort = 123;
  56. Req.tuchar = 'I';
  57. Req.tstring = "SampleService_TwoWayFuncNormal_Req::tstring::xclvmsdiofjweoij3r283908u238925j4ioijn;klgnfakjsfsfhffjeoiwjhoi";
  58. Req.twstring = "SampleService_TwoWayFuncNormal_Req::twstring::xclvmsdiofjweoij3r283908u238925j4ioijn;klgnfakjsfsfhffjeoiwjhoi";
  59. Req.tfloat = 123.456f;
  60. Req.tdouble = 123.456;
  61. Req.tblob.Clear();
  62. Req.tint64 = 123;
  63. Req.tuint64 = 123;
  64. ANSWER_CHECK(Ans.sarray_string.GetCount() == 2); /*this would pass*/
  65. ANSWER_REQUIRE(Ans.sarray_string[0] == "String1"); /*this would pass*/
  66. ANSWER_REQUIRE(Ans.sarray_string[1] == "String3"); /*this would be failed, abort*/
  67. ANSWER_CHECK(Ans.sarray_string[2] == "String3"); /*this would not invoke*/
  68. }
  69. SP_BEGIN_ENTITY_MAP()
  70. SP_ENTITY(CSampleEntity)
  71. SP_END_ENTITY_MAP()