package Ġuk . n hs . n hs x . covid 1 9 . android . app . test ordering . link test result Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġio . mock k . called Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify Ċ import Ġio . mock k . verify Order Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġuk . n hs . n hs x . covid 1 9 . android . app . analytics . Analytics Event . Did Ask For Sy mptoms On Positive Test Entry Ċ import Ġuk . n hs . n hs x . covid 1 9 . android . app . analytics . Analytics Event . Did Have Sy mptoms Before Received TestResult Ċ import Ġuk . n hs . n hs x . covid 1 9 . android . app . analytics . Analytics Event Processor Ċ Ċ class ĠLink TestResult Sy mptoms ViewModel Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġval Ġanalytics Event Processor Ġ= Ġmock k < Analytics Event Processor >( relax ed Ġ= Ġtrue ) ĊĊĠĠĠ Ġprivate Ġval Ġconfirm Sy mptoms Observer Ġ= Ġmock k < Observer < Unit >>( relax ed Ġ= Ġtrue ) ĊĊĠĠĠ Ġprivate Ġval Ġtest Subject Ġ= ĠLink TestResult Sy mptoms ViewModel ( analytics Event Processor ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest Subject . confirm Sy mptoms (). observe Fore ver ( confirm Sy mptoms Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` onCreate Ġshould Ġtrigger Ġanalytics Ġevent ĠDid Ask For Sy mptoms On Positive Test Entry `() Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġtest Subject . onCreate () ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġanalytics Event Processor . track ( Did Ask For Sy mptoms On Positive Test Entry ) Ġ} ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġconfirm Sy mptoms Observer Ġwas Not Ġcalled Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` repeated ly Ġcalling ĠonCreate Ġshould Ġtrigger Ġanalytics Ġevent ĠDid Ask For Sy mptoms On Positive Test Entry Ġonly Ġonce `() Ġ= ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Subject . onCreate () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Subject . onCreate () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Subject . onCreate () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġanalytics Event Processor . track ( Did Ask For Sy mptoms On Positive Test Entry ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify Ġ{ Ġconfirm Sy mptoms Observer Ġwas Not Ġcalled Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` on Confirm Sy mptoms Clicked Ġshould Ġtrigger Ġanalytics Ġevent ĠDid Have Sy mptoms Before Received TestResult Ġand Ġemit Ġconfirm Sy mptoms Ġevent `() Ġ= ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtest Subject . on Confirm Sy mptoms Clicked () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify Order Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġanalytics Event Processor . track ( Did Have Sy mptoms Before Received TestResult ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconfirm Sy mptoms Observer . on Changed ( null ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ċ } Ċ