package Ġcom . w im ank . pb fs . room Ċ Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . w im ank . pb fs . room . dao . User Dao Ċ import Ġcom . w im ank . pb fs . room . entity . User Entity Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ Experimental Cor outines Api Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠUser Dao Test Ġ: ĠData Base Test () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġuser Dao : ĠUser Dao Ġby Ġlazy Ġ{ Ġdb . getUser Dao () Ġ} ĊĠĠĠ Ġprivate Ġval Ġuser Entity Ġ= ĠUser Entity ( name Ġ= Ġ" n ", Ġavatar Ġ= Ġ" a ", Ġupdate Time Ġ= Ġ 1 0 0 ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġflow User () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġuser Dao . insert ( user Entity ) ĊĠĠĠĠĠĠĠ ĠassertThat ( user Dao . flow User (). first ()). isEqualTo ( user Entity ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget UpdateTime () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġuser Dao . insert ( user Entity ) ĊĠĠĠĠĠĠĠ ĠassertThat ( user Dao . get UpdateTime ()). isEqualTo ( 1 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclear User () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġuser Dao . clear User () ĊĠĠĠĠĠĠĠ ĠassertThat ( user Dao . getUser ()). isNull () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclear And Insert User () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġuser Dao . clear And Insert User ( user Entity ) ĊĠĠĠĠĠĠĠ ĠassertThat ( user Dao . getUser ()). isEqualTo ( user Entity ) ĊĠĠĠ Ġ} Ċ } Ċ