package Ġcom . es cod ro . domain . use case . task with category Ċ Ċ import Ġcom . es cod ro . domain . model . Category Ċ import Ġcom . es cod ro . domain . model . Task Ċ import Ġcom . es cod ro . domain . use case . fake . Category Repository Fake Ċ import Ġcom . es cod ro . domain . use case . fake . Task Repository Fake Ċ import Ġcom . es cod ro . domain . use case . fake . Task With Category Repository Fake Ċ import Ġcom . es cod ro . domain . use case . task with category . implementation . Load Un completed Tasks Impl Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ @ Experimental Cor outines Api Ċ internal Ġclass ĠLoad Tasks Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġtask Repository Ġ= ĠTask Repository Fake () ĊĊĠĠĠ Ġprivate Ġval Ġcategory Repository Ġ= ĠCategory Repository Fake () ĊĊĠĠĠ Ġprivate Ġval Ġtask With Category Repository Ġ= ĊĠĠĠĠĠĠĠ ĠTask With Category Repository Fake ( task Repository , Ġcategory Repository ) ĊĊĠĠĠ Ġprivate Ġval Ġload Completed Tasks UseCase Ġ= ĠLoad Completed Tasks ( task With Category Repository ) ĊĊĠĠĠ Ġprivate Ġval Ġload Un completed Tasks UseCase Ġ= ĠLoad Un completed Tasks Impl ( task With Category Repository ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcategory 1 Ġ= ĠCategory ( id Ġ= Ġ 1 , Ġname Ġ= Ġ" cat 1 ", Ġcolor Ġ= Ġ"# FFFFFF ") ĊĠĠĠĠĠĠĠ Ġval Ġcategory 2 Ġ= ĠCategory ( id Ġ= Ġ 2 , Ġname Ġ= Ġ" cat 2 ", Ġcolor Ġ= Ġ"# 0 0 0 0 0 0 ") ĊĠĠĠĠĠĠĠ Ġcategory Repository . insert Category ( listOf ( category 1 , Ġcategory 2 )) ĊĊĠĠĠĠĠĠĠ Ġval Ġtask 1 Ġ= ĠTask ( 1 , Ġtitle Ġ= Ġ" Task Ġ 1 ", Ġcompleted Ġ= Ġfalse , Ġcategory Id Ġ= Ġcategory 2 . id ) ĊĠĠĠĠĠĠĠ Ġval Ġtask 2 Ġ= ĠTask ( 2 , Ġtitle Ġ= Ġ" Task Ġ 2 ", Ġcompleted Ġ= Ġtrue , Ġcategory Id Ġ= Ġcategory 2 . id ) ĊĠĠĠĠĠĠĠ Ġval Ġtask 3 Ġ= ĠTask ( 3 , Ġtitle Ġ= Ġ" Task Ġ 3 ", Ġcompleted Ġ= Ġtrue , Ġcategory Id Ġ= Ġcategory 1 . id ) ĊĠĠĠĠĠĠĠ Ġval Ġtask 4 Ġ= ĠTask ( 4 , Ġtitle Ġ= Ġ" Task Ġ 4 ", Ġcompleted Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ Ġval Ġtask List Ġ= ĠlistOf ( task 1 , Ġtask 2 , Ġtask 3 , Ġtask 4 ) ĊĠĠĠĠĠĠĠ Ġtask List . forEach Ġ{ Ġtask Ġ-> Ġtask Repository . insert Task ( task ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġtask Repository . clean Table () ĊĠĠĠĠĠĠĠ Ġcategory Repository . clean Table () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġif Ġcompleted Ġtasks Ġare Ġfiltered `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompleted Tasks Ġ= Ġload Completed Tasks UseCase (). first () ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 2 , Ġcompleted Tasks . size ) ĊĠĠĠĠĠĠĠ Ġcompleted Tasks . forEach Ġ{ Ġtask With Category Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertTrue ( task With Category . task . completed ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġif Ġun completed Ġtasks Ġare Ġfiltered `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġun completed Tasks Ġ= Ġload Un completed Tasks UseCase (). first () ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 2 , Ġun completed Tasks . size ) ĊĠĠĠĠĠĠĠ Ġun completed Tasks . forEach Ġ{ Ġtask With Category Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertFalse ( task With Category . task . completed ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġif Ġun completed Ġtasks Ġare Ġfiltered Ġby Ġcategory `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġun completed Tasks By Category Ġ= Ġload Un completed Tasks UseCase ( 2 L ). first () ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 1 , Ġun completed Tasks By Category . size ) ĊĠĠĠĠĠĠĠ Ġun completed Tasks By Category . forEach Ġ{ Ġtask With Category Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertFalse ( task With Category . task . completed ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ