package Ġfi . ef el ant ti . fr is be eg ol fer Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġfi . ef el ant ti . fr is be eg ol fer . dao . Course Dao Ċ import Ġfi . ef el ant ti . fr is be eg ol fer . dao . Player Dao Ċ import Ġfi . ef el ant ti . fr is be eg ol fer . dao . Round Dao Ċ import Ġfi . ef el ant ti . fr is be eg ol fer . model .* Ċ import Ġio . mock k .* Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . hamcrest . Core Matchers . equalTo Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ import Ġjava . io . Invalid Object Exception Ċ import Ġjava . time . Offset DateTime Ċ import Ġjava . time . Zone Offset ĊĊ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ /* Ċ Using ĠMockito Ġand ĠMock K Ġfor Ġmock ing Ġpurposes . ĠCould n 't Ġget ĠMockito Ġto Ġwork Ġproperly Ġwith Ġsuspend Ġfunctions , Ġso ĠMock K Ġis Ġused Ġin Ġthose Ġtests Ġinstead . ĠEvery Ġtest Ċ could Ġbe Ġref actored Ġto Ġuse ĠMock K Ġfor Ġcont istency . Ċ Ġ*/ Ċ @ Experimental Cor outines Api Ċ class ĠRepository Tests Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrepository : ĠRepository ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdb : ĠFr is be eg ol fer Room Database ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfake Player Dao : ĠPlayer Dao ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfake Course Dao : ĠCourse Dao ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfake Round Dao : ĠRound Dao ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetAll Players When Empty () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( fake Player Dao . get Players ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Mutable LiveData ( emptyList ())) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġval Ġall Players Ġ= Ġrepository . all Players ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġall Players . getValue Blocking () Ġ?: Ġthrow ĠInvalid Object Exception (" null Ġreturned Ġas Ġplayers ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result . count (), ĠequalTo ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetAll Players When Non Empty () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( fake Player Dao . get Players ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Mutable LiveData ( listOf ( Player ( name Ġ= Ġ" Tester 1 "), ĠPlayer ( name = Ġ" Tester 2 "), ĠPlayer ( name =" Tester 3 ")) )) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġval Ġall Players Ġ= Ġrepository . all Players ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġall Players . getValue Blocking () Ġ?: Ġthrow ĠInvalid Object Exception (" null Ġreturned Ġas Ġplayers ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result . count (), ĠequalTo ( 3 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 0 ]. name , ĠequalTo (" Tester 1 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 1 ]. name , ĠequalTo (" Tester 2 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 2 ]. name , ĠequalTo (" Tester 3 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetAll Courses When Empty () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( fake Course Dao . getC our ses With Ho les ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Mutable LiveData ( emptyList ())) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġval Ġall Courses Ġ= Ġrepository . all Courses ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġall Courses . getValue Blocking () Ġ?: Ġthrow ĠInvalid Object Exception (" null Ġreturned Ġas Ġplayers ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result . count (), ĠequalTo ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetAll Courses When Non Empty () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( fake Course Dao . getC our ses With Ho les ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Mutable LiveData ( listOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCourse With Ho les ( Course ( name Ġ= Ġ" Course 1 ", Ġcity = Ġ" City 1 "), Ġholes = listOf ( Hole (), ĠH ole ())), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCourse With Ho les ( Course ( name Ġ= Ġ" Course 2 ", Ġcity = Ġ" City 2 "), Ġholes = listOf ( Hole (), ĠH ole (), ĠH ole ())) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ))) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġval Ġall Courses Ġ= Ġrepository . all Courses ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġall Courses . getValue Blocking () Ġ?: Ġthrow ĠInvalid Object Exception (" null Ġreturned Ġas Ġplayers ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result . count (), ĠequalTo ( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 0 ]. course . name , ĠequalTo (" Course 1 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 0 ]. course . city , ĠequalTo (" City 1 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 1 ]. course . name , ĠequalTo (" Course 2 ")) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 1 ]. course . city , ĠequalTo (" City 2 ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetAll Round s When Empty () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( fake Round Dao . get Round s ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Mutable LiveData ( emptyList ())) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġval Ġall Round s Ġ= Ġrepository . all Round s ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġall Round s . getValue Blocking () Ġ?: Ġthrow ĠInvalid Object Exception (" null Ġreturned Ġas Ġplayers ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result . count (), ĠequalTo ( 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetAll Round s When Non Empty () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġround Id Ġ= ĠOffset DateTime . of ( 2 0 2 0 , Ġ 1 2 , 3 1 , 1 2 , 0 , 0 , 0 , ĠZone Offset . UTC ) ĊĠĠĠĠĠĠĠ Ġval Ġround Id 2 Ġ= ĠOffset DateTime . of ( 2 0 1 0 , Ġ 6 , 1 , 1 2 , 0 , 0 , 0 , ĠZone Offset . UTC ) ĊĊĠĠĠĠĠĠĠ Ġ` when `( fake Round Dao . get Round s ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMutable LiveData ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRound With Course And Scores ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRound ( course Id Ġ= Ġ 0 , Ġdate Started Ġ= Ġround Id ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScore With Player And Hole ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhole Ġ= ĠH ole (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġplayer Ġ= ĠPlayer (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġscore Ġ= ĠScore ( parent Round Id Ġ= Ġround Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCourse With Ho les ( Course (), Ġempty List ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRound With Course And Scores ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠRound ( course Id Ġ= Ġ 1 , Ġdate Started Ġ= Ġround Id 2 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScore With Player And Hole ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhole Ġ= ĠH ole (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġplayer Ġ= ĠPlayer (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġscore Ġ= ĠScore ( parent Round Id Ġ= Ġround Id 2 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCourse With Ho les ( Course (), Ġempty List ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġval Ġall Round s Ġ= Ġrepository . all Round s ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġall Round s . getValue Blocking () Ġ?: Ġthrow ĠInvalid Object Exception (" null Ġreturned Ġas Ġplayers ") ĊĠĠĠĠĠĠĠ ĠassertThat ( result . count (), ĠequalTo ( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 0 ]. round . date Started , ĠequalTo ( round Id )) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 0 ]. round . course Id , ĠequalTo ( 0 L )) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 1 ]. round . date Started , ĠequalTo ( round Id 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( result [ 1 ]. round . course Id , ĠequalTo ( 1 L )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinsert Player () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġplayer Ġ= ĠPlayer ( name =" Tester ") ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . insert ( player ) ĊĠĠĠĠĠĠĠ Ġverify ( fake Player Dao ). insert ( player ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinsert Round () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġround Ġ= ĠRound ( date Started Ġ= ĠOffset DateTime . now (), Ġcourse Id Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . insert ( round ) ĊĠĠĠĠĠĠĠ Ġverify ( fake Round Dao ). insert ( round ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinsert Score () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġscore Ġ= ĠScore ( parent Round Id Ġ= ĠOffset DateTime . now ()) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . insert ( score ) ĊĠĠĠĠĠĠĠ Ġverify ( fake Round Dao ). insert ( score ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Player () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġplayer Ġ= ĠPlayer ( name =" Tester ") ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . update ( player ) ĊĠĠĠĠĠĠĠ Ġverify ( fake Player Dao ). update ( player ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Score () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġscore Ġ= ĠScore ( parent Round Id Ġ= ĠOffset DateTime . now ()) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . update ( score ) ĊĠĠĠĠĠĠĠ Ġverify ( fake Round Dao ). update ( score ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Hole () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġhole Ġ= ĠH ole () ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . delete ( hole ) ĊĠĠĠĠĠĠĠ Ġverify ( fake Course Dao ). delete ( hole ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Round With Scores () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġround Id Ġ= ĠOffset DateTime . of ( 2 0 2 0 , 1 , 1 , 1 2 , 0 , 0 , 0 , ĠZone Offset . UTC ) ĊĠĠĠĠĠĠĠ Ġval Ġround Ġ= ĠRound ( round Id , Ġcourse Id Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġround With Course And Scores Ġ= ĠRound With Course And Scores ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġround , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScore With Player And Hole ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhole Ġ= ĠH ole (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġplayer Ġ= ĠPlayer (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġscore Ġ= ĠScore ( parent Round Id Ġ= Ġround Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCourse With Ho les ( Course (), Ġempty List ()) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġalternative Mock Ġ= Ġmock k < Round Dao >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . get Round s () Ġ} Ġreturns ĠMutable LiveData ( emptyList ()) ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġalternative Mock . delete ( round With Course And Scores . round ) Ġ} Ġreturns ĠUnit ĊĠĠĠĠĠĠĠ Ġfor Ġ( score Ġin Ġround With Course And Scores . scores ) ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġalternative Mock . delete ( score . score ) Ġ} Ġreturns ĠUnit ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġalternative Mock ) ĊĠĠĠĠĠĠĠ Ġrepository . delete ( round With Course And Scores ) ĊĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . delete ( round With Course And Scores . round ) Ġ} ĊĠĠĠĠĠĠĠ Ġfor Ġ( score Ġin Ġround With Course And Scores . scores ) ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . delete ( score . score )} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Course With Ho les () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcourse With Ho les Ġ= ĠCourse With Ho les ( Course (), ĠlistOf ( Hole ())) ĊĠĠĠĠĠĠĠ Ġval Ġalternative Mock Ġ= Ġmock k < Course Dao >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . getC our ses With Ho les () Ġ} Ġreturns ĠMutable LiveData < List < Course With Ho les >>( emptyList ()) ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġalternative Mock . update ( course With Ho les . course ) Ġ} Ġreturns ĠUnit ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġalternative Mock . update All ( course With Ho les . ho les ) Ġ} Ġreturns ĠUnit ĊĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġalternative Mock , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . update ( course With Ho les ) ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . update ( course With Ho les . course )} ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . update All ( course With Ho les . ho les )} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinsert Course With Ho les () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcourse With Ho les Ġ= ĠCourse With Ho les ( Course (), ĠlistOf ( Hole ())) ĊĠĠĠĠĠĠĠ Ġval Ġalternative Mock Ġ= Ġmock k < Course Dao >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . getC our ses With Ho les () Ġ} Ġreturns ĠMutable LiveData < List < Course With Ho les >>( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġempty List () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġalternative Mock . insert ( course With Ho les . course ) Ġ} Ġreturns Ġ 0 ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġalternative Mock . insert All ( course With Ho les . ho les ) Ġ} Ġreturns ĠUnit ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġalternative Mock , Ġfake Round Dao ) ĊĠĠĠĠĠĠĠ Ġrepository . insert Course With Ho les ( course With Ho les ) ĊĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . insert ( course With Ho les . course ) Ġ} ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . insert All ( course With Ho les . ho les ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Course With Ho les ById () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcourse With Ho les Ġ= ĠCourse With Ho les ( Course (), ĠlistOf ( Hole ())) ĊĊĠĠĠĠĠĠĠ Ġval Ġalternative Mock Ġ= Ġmock k < Course Dao >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . getC our ses With Ho les () Ġ} Ġreturns ĠMutable LiveData < List < Course With Ho les >>( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġempty List () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . getC ourse With Ho les With Id ( 0 ) Ġ} Ġreturns ĠMutable LiveData ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse With Ho les ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġalternative Mock , Ġfake Round Dao ) ĊĊĠĠĠĠĠĠĠ Ġrepository . getC ourse With Ho les ById ( 0 ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . getC ourse With Ho les With Id ( 0 ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Round With Round Id () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġround Id Ġ= ĠOffset DateTime . of ( 2 0 2 0 , 1 , 1 , 1 2 , 0 , 0 , 0 , ĠZone Offset . UTC ) ĊĠĠĠĠĠĠĠ Ġval Ġround Ġ= ĠRound ( round Id , Ġcourse Id Ġ= Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġround With Course And Scores Ġ= ĠRound With Course And Scores ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġround , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠScore With Player And Hole ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhole Ġ= ĠH ole (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġplayer Ġ= ĠPlayer (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġscore Ġ= ĠScore ( parent Round Id Ġ= Ġround Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCourse With Ho les ( Course (), Ġempty List ()) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġalternative Mock Ġ= Ġmock k < Round Dao >() ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . get Round s () Ġ} Ġreturns ĠMutable LiveData < List < Round With Course And Scores >>( emptyList ()) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . get Round With Id ( round Id )} Ġreturns ĠMutable LiveData ( round With Course And Scores ) ĊĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġalternative Mock ) ĊĠĠĠĠĠĠĠ Ġrepository . get Round With Round Id ( round Id ) ĊĊĠĠĠĠĠĠĠ Ġverify Ġ( Ġexactly Ġ= Ġ 1 Ġ) Ġ{ Ġalternative Mock . get Round With Id ( round Id )} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Hole Statistics () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġalternative Mock Ġ= Ġmock k < Round Dao >() ĊĠĠĠĠĠĠĠ Ġval Ġhole Id Ġ= Ġ 0 L ĊĠĠĠĠĠĠĠ Ġval Ġplayer Id Ġ= Ġ 0 L ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . get Round s () Ġ} Ġreturns ĠMutable LiveData < List < Round With Course And Scores >>( emptyList ()) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġalternative Mock . get Hole Statistics ( player Id , Ġhole Id )} Ġreturns ĠMutable LiveData < Hole Statistics >( Hole Statistics ( best Result = 1 , Ġavg Result = 1 . 5 f , Ġlatest Result = 2 )) ĊĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠRepository ( db , Ġfake Player Dao , Ġfake Course Dao , Ġalternative Mock ) ĊĠĠĠĠĠĠĠ Ġrepository . get Hole Statistics ( player Id , Ġhole Id ) ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġalternative Mock . get Hole Statistics ( player Id , Ġhole Id )} ĊĠĠĠ Ġ} Ċ }