package Ġcom . j house . simple flash card . db Ċ Ċ import Ġcom . j house . simple flash card . db . config . Config Entity Ċ import Ġcom . j house . simple flash card . db . player . Player Entity Ċ import Ġcom . j house . simple flash card . etc . Root Test Ċ import Ġcom . j house . simple flash card . question . Question Type Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertNotNull Ċ import Ġorg . junit . Test Ċ Ċ class ĠPlayer Dao Test Ġ: ĠRoot Test () Ġ{ ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Insert Player () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠData ĠSetup ĊĠĠĠĠĠĠĠ Ġval Ġexpected Player Ġ= ĠPlayer Entity ( 2 , Ġ" TEST ") ĊĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠScenario ( When ) ĊĠĠĠĠĠĠĠ Ġdb . player Dao (). insert Player ( expected Player ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠExpected Ġresult Ġ( assert ) ĊĠĠĠĠĠĠĠ Ġvar Ġcursor Ġ= Ġsql Executor . select (" Player ") ĊĠĠĠĠĠĠĠ Ġcursor . moveTo Last () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( expected Player . id , Ġcursor . getInt ( cursor . getColumnIndex (" id "))) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( expected Player . name , Ġcursor . getString ( cursor . getColumnIndex (" name "))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠtestGet Players () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠData ĠSetup ĊĠĠĠĠĠĠĠ Ġval Ġexpected Player Entity = Player Entity ( 2 , Ġ" test ") ĊĠĠĠĠĠĠĠ Ġval Ġexpected Config Entity = ĠConfig Entity ( 2 , ĠQuestion Type . CHO ICES _ 4 , Ġ 1 0 , Ġ 1 1 , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Player Count Ġ= Ġ 2 ĊĊĠĠĠĠĠĠĠ Ġdb . player Dao (). insert Player ( expected Player Entity ) ĊĠĠĠĠĠĠĠ Ġdb . config Dao (). insert Config ( expected Config Entity ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠScenario ( When ) ĊĠĠĠĠĠĠĠ Ġval Ġactual Player Ġ= Ġdb . player Dao (). get Players () ĊĊĠĠĠĠĠĠĠ Ġ// ĠExpected Ġresult Ġ( assert ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Player Count , actual Player . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Player Entity . name , actual Player . last (). player . name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠtestGet Players ByName () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠData ĠSetup ĊĠĠĠĠĠĠĠ Ġval Ġexpected Player Entity = Player Entity ( 2 , Ġ" test ") ĊĠĠĠĠĠĠĠ Ġval Ġexpected Config Entity = ĠConfig Entity ( 2 , ĠQuestion Type . CHO ICES _ 4 , Ġ 1 0 , Ġ 1 1 , Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġdb . player Dao (). insert Player ( expected Player Entity ) ĊĠĠĠĠĠĠĠ Ġdb . config Dao (). insert Config ( expected Config Entity ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠScenario ( When ) ĊĠĠĠĠĠĠĠ Ġval Ġactual Player Ġ= Ġdb . player Dao (). getPlayer ByName (" test ") ĊĊĠĠĠĠĠĠĠ Ġ// ĠExpected Ġresult Ġ( assert ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Player Entity . id , actual Player . player . id ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Player Entity . name , actual Player . player . name ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Config Entity . question Type , actual Player . config . question Type ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Config Entity . question Count , actual Player . config . question Count ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Config Entity . time Limit Secs , actual Player . config . time Limit Secs ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Config Entity . save Result , actual Player . config . save Result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Update Player () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠData ĠSetup ĊĠĠĠĠĠĠĠ Ġval Ġold Player Entity = Player Entity ( 2 , Ġ" test ") ĊĠĠĠĠĠĠĠ Ġval Ġnew Player Entity = Player Entity ( 2 , Ġ" new _ player ") ĊĠĠĠĠĠĠĠ Ġval Ġold Config Entity = ĠConfig Entity ( 2 , ĠQuestion Type . CHO ICES _ 4 , Ġ 1 0 , Ġ 1 1 , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġdb . player Dao (). insert Player ( old Player Entity ) ĊĠĠĠĠĠĠĠ Ġdb . config Dao (). insert Config ( old Config Entity ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠScenario ( When ) ĊĠĠĠĠĠĠĠ Ġdb . player Dao (). update Player ( new Player Entity ) ĊĠĠĠĠĠĠĠ Ġval Ġactual Player = db . player Dao (). getPlayer ByName (" new _ player ") ĊĊĠĠĠĠĠĠĠ Ġ// ĠExpected Ġresult Ġ( assert ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( actual Player ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( new Player Entity . name , actual Player . player . name ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Delete Player (): ĠUnit Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠData ĠSetup ĊĠĠĠĠĠĠĠ Ġval Ġexpected Player Entity = Player Entity ( 2 , Ġ" test ") ĊĠĠĠĠĠĠĠ Ġval Ġexpected Config Entity = ĠConfig Entity ( 2 , ĠQuestion Type . CHO ICES _ 4 , Ġ 1 0 , Ġ 1 1 , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Player Count After Add Player Ġ= 2 ĊĠĠĠĠĠĠĠ Ġval Ġexpected Player Count After Del Player Ġ= 1 ĊĠĠĠĠĠĠĠ Ġdb . player Dao (). insert Player ( expected Player Entity ) ĊĠĠĠĠĠĠĠ Ġdb . config Dao (). insert Config ( expected Config Entity ) ĊĠĠĠĠĠĠĠ Ġvar Ġadded Player Ġ= Ġdb . player Dao (). get Players () ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Player Count After Add Player , added Player . size ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠTest ĠScenario ( When ) ĊĠĠĠĠĠĠĠ Ġdb . player Dao (). delete Player ( expected Player Entity ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠExpected Ġresult Ġ( assert ) ĊĠĠĠĠĠĠĠ Ġval Ġafter Delete Player Ġ= Ġdb . player Dao (). get Players () ĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Player Count After Del Player , after Delete Player . size ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcursor Ġ= sql Executor . select By Where (" Config "," Config . player _ id Ġ= 2 ") ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , cursor . count ) ĊĊĊĠĠĠ Ġ} Ċ }