package Ġid . ap w devs . app . libs . util Ċ Ċ import Ġandroid . content . Context Ċ import Ġid . ap w devs . app . libs . rule . Test Coroutine Rule Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . test . Test Coroutine Scope Ċ import Ġokhttp 3 . mock webserver . Mock Response ĊĊ Ċ fun ĠContext . provide Response ( custom Asset Json : ĠString , Ġresponse Code : ĠInt ): ĠMock Response Ġ{ ĊĊĠĠĠ Ġreturn ĠMock Response () ĊĠĠĠĠĠĠĠ Ġ. set Response Code ( response Code ) ĊĠĠĠĠĠĠĠ Ġ. set Body ( read Json ( custom Asset Json )) Ċ } Ċ Ċ fun ĠContext . read Json ( path : ĠString ): ĠString Ġ{ ĊĠĠĠ Ġval Ġi Stream Ġ= Ġassets . open ( path ) ĊĠĠĠ Ġval Ġbyte Arr Ġ= ĠByteArray ( i Stream . available ()) ĊĠĠĠ Ġi Stream . read ( byte Arr ) ĊĠĠĠ Ġval Ġstr Result Ġ= ĠString ( byte Arr ) ĊĠĠĠ Ġi Stream . close () ĊĠĠĠ Ġreturn Ġstr Result Ċ } Ċ Ċ @ Experimental Cor outines Api Ċ fun Ġrun Test ( test Coroutine Rule : ĠTest Coroutine Rule , Ġscope : Ġsuspend ĠTest Coroutine Scope . () Ġ-> ĠUnit ) Ġ{ ĊĠĠĠ Ġtest Coroutine Rule . run Blocking Test ( scope ) Ċ }