S3PTestCardInfoDAO.cpp
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 3k
Development Platform:

C/C++

  1. // S3PTestCardInfoDAO.cpp: implementation of the S3PTestCardInfoDAO class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "S3PTestCardInfoDAO.h"
  5. #include "S3PDBConnection.h"
  6. #include "S3PRow.h"
  7. #include "S3PCardInfoDAO.h"
  8. #include "S3PDBConnector.h"
  9. //////////////////////////////////////////////////////////////////////
  10. // Construction/Destruction
  11. //////////////////////////////////////////////////////////////////////
  12. S3PTestCardInfoDAO::~S3PTestCardInfoDAO()
  13. {
  14. }
  15. void S3PTestCardInfoDAO::testAdd()
  16. {
  17. S3PDBConnection* pCardCon = // 连接角色数据库
  18. S3PDBConnector::Instance()->ApplyDBConnection( def_CARDDB );
  19. if (NULL != pCardCon)
  20. {
  21. S3PCardInfoDAO card(pCardCon);
  22. ColumnAndValue cav;
  23. cav["cCardCode"] = "001";
  24. cav["cCardPassWord"] = "1111";
  25. cav["iFlag"]="1";
  26. cav["iHoldSecond"]="1000";
  27. cav["iHoldMonth"]="6";
  28. S3PRow row(card.GetTableName(), &cav, pCardCon);
  29. if ( card.Add(&row) <= 0 )
  30. {
  31. assert(false);
  32. }
  33. pCardCon->Close();
  34. }
  35. }
  36. void S3PTestCardInfoDAO::testUpdate()
  37. {
  38. /* S3PDBConnection* pCardCon = // 连接角色数据库
  39. S3PDBConnector::Instance()->ApplyDBConnection( def_CARDDB );
  40. if (NULL != pCardCon)
  41. {
  42. S3PCardInfoDAO card(pCardCon);
  43. ColumnAndValue cav,cavWhere;
  44. cav["cCardPassWord"] = "101010";
  45. cavWhere["cCardCode"] = "001";
  46. S3PRow row(card.GetTableName(), &cav,pCardCon);
  47. S3PRow rowWhere(card.GetTableName(),&cavWhere,pCardCon);
  48. card.Update(&row,&rowWhere);
  49. S3PResult * res;
  50. std::string strQuery;
  51. strQuery = "select * from cardinfo where ccardcode like '001' ";
  52. card.GetCardInfoResult(strQuery,res);
  53. if ( res->rows() != 1)
  54. {
  55. assert(false);
  56. }
  57. else
  58. {
  59. ColumnAndValue cavPassWord;
  60. cavPassWord = ( * res )[0];
  61. if ( cavPassWord["ccardpassword"] != "101010" )
  62. {
  63. assert( false );
  64. }
  65. }
  66. pCardCon->Close();
  67. }*/
  68. }
  69. void S3PTestCardInfoDAO::testDelete()
  70. {
  71. S3PDBConnection* pCardCon = // 连接角色数据库
  72. S3PDBConnector::Instance()->ApplyDBConnection( def_CARDDB );
  73. if (NULL != pCardCon)
  74. {
  75. S3PCardInfoDAO card(pCardCon);
  76. ColumnAndValue cav;
  77. cav["cCardCode"] = "001";
  78. //cav["cCardPassWord"] = "1111";
  79. //cav["iFlag"]="1";
  80. //cav["iHoldSecond"]="1000";
  81. //cav["iHoldMonth"]="6";
  82. S3PRow row(card.GetTableName(), &cav, pCardCon);
  83. if ( card.Delete(& row) <= 0 )
  84. {
  85. assert(false);
  86. }
  87. pCardCon->Close();
  88. }
  89. }
  90. Test *S3PTestCardInfoDAO::suite ()
  91. {
  92. TestSuite *testSuite = new TestSuite ("Test CardInfo Table Manipulator");
  93. testSuite->addTest (new TestCaller <S3PTestCardInfoDAO> ("testCardInfoAdd", testAdd));
  94.     testSuite->addTest (new TestCaller <S3PTestCardInfoDAO> ("testCardInfoUpdate", testUpdate));
  95.     testSuite->addTest (new TestCaller <S3PTestCardInfoDAO> ("testCardInfoDelete", testDelete));
  96.     
  97. return testSuite;
  98. }
  99. void S3PTestCardInfoDAO::setUp()
  100. {
  101. }