Example #1
0
void tstTeamMngr::testGetAllTeams()
{
  printStartMsg("tstTeamMngr::testGetAllTeams");
  
  TournamentDB* db = getScenario01(true);
  TeamMngr tmngr(db);
  
  // run on empty table
  QList<Team> result = tmngr.getAllTeams();
  CPPUNIT_ASSERT(result.length() == 0);
  
  // actually create a valid team
  CPPUNIT_ASSERT(tmngr.createNewTeam("t1") == OK);
  CPPUNIT_ASSERT(tmngr.createNewTeam("t2") == OK);
  
  // run on filled table
  result = tmngr.getAllTeams();
  CPPUNIT_ASSERT(result.length() == 2);
  Team t = result.at(0);
  CPPUNIT_ASSERT(t.getId() == 1);
  CPPUNIT_ASSERT(t.getName() == "t1");
  t = result.at(1);
  CPPUNIT_ASSERT(t.getId() == 2);
  CPPUNIT_ASSERT(t.getName() == "t2");
  
  delete db;
  printEndMsg();
}
Example #2
0
void tstTeamMngr::testGetTeam()
{
  printStartMsg("tstTeamMngr::testGetTeam");
  
  TournamentDB* db = getScenario01(true);
  TeamMngr tmngr(db);
  
  // actually create a valid team
  CPPUNIT_ASSERT(tmngr.createNewTeam("t1") == OK);
  CPPUNIT_ASSERT(tmngr.createNewTeam("t2") == OK);
  
  // try queries on filled table
  CPPUNIT_ASSERT_THROW(tmngr.getTeam(""), std::invalid_argument);
  CPPUNIT_ASSERT_THROW(tmngr.getTeam(QString::null), std::invalid_argument);
  CPPUNIT_ASSERT_THROW(tmngr.getTeam("dflsjdf"), std::invalid_argument);
  Team t = tmngr.getTeam("t2");
  CPPUNIT_ASSERT(t.getId() == 2);
  CPPUNIT_ASSERT(t.getName() == "t2");
  
  delete db;
  printEndMsg();
}
Example #3
0
bool operator==( const Team &one, const Team &another )
{
    return one.getId() == another.getId();
}