/* Ċ Ġ* ĠCopyright Ġ 2 0 2 1 ĠEric ĠA . ĠSn ell Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . e al va . to que . db . smart Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġcom . e al va . to que . common . Star Rating Ċ import Ġcom . e al va . to que . db . Media Table Ċ import Ġcom . n ha ar man . expect . expect Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith ĊĊ Ċ @ Experimental Cor outines Api Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠRating Android Matcher Test Ġ{ ĊĠ Ġprivate Ġlateinit Ġvar Ġapp Ctx : ĠContext ĊĊĠ Ġ@ Before ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ Ġapp Ctx Ġ= ĠApplication Provider . getApplicationContext () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Is () Ġ{ ĊĠĠĠ Ġval Ġmatcher Ġ= ĠRating Matcher . Is ĊĠĠĠ Ġval Ġclause Ġ= Ġmatcher . make Where Clause ( Media Table . rating , ĠMatcher Data ( Star Rating . STAR _ NONE )) ĊĠĠĠ Ġexpect ( clause . toString ()). toBe (""" Media . Media Rating Ġ= Ġ- 1 """) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest IsNot () Ġ{ ĊĠĠĠ Ġval Ġmatcher Ġ= ĠRating Matcher . IsNot ĊĠĠĠ Ġval Ġclause Ġ= Ġmatcher . make Where Clause ( Media Table . rating , ĠMatcher Data ( Star Rating . STAR _ 5 )) ĊĠĠĠ Ġexpect ( clause . toString ()). toBe (""" Media . Media Rating Ġ<> Ġ 1 0 0 """) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Is GreaterThan () Ġ{ ĊĠĠĠ Ġval Ġmatcher Ġ= ĠRating Matcher . Is GreaterThan ĊĠĠĠ Ġval Ġclause Ġ= Ġmatcher . make Where Clause ( Media Table . rating , ĠMatcher Data ( Star Rating . STAR _ 4 )) ĊĠĠĠ Ġexpect ( clause . toString ()). toBe (""" Media . Media Rating Ġ> Ġ 8 0 """) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Is LessThan () Ġ{ ĊĠĠĠ Ġval Ġmatcher Ġ= ĠRating Matcher . Is LessThan ĊĠĠĠ Ġval Ġclause Ġ= Ġmatcher . make Where Clause ( Media Table . rating , ĠMatcher Data ( Star Rating . STAR _ 2 )) ĊĠĠĠ Ġexpect ( clause . toString ()). toBe (""" Media . Media Rating Ġ< Ġ 4 0 """) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest IsIn The Range () Ġ{ ĊĠĠĠ Ġval Ġmatcher Ġ= ĠRating Matcher . IsIn The Range ĊĠĠĠ Ġval Ġclause Ġ= ĊĠĠĠĠĠ Ġmatcher . make Where Clause ( Media Table . rating , ĠMatcher Data ( Star Rating . STAR _ 0 , ĠStar Rating . STAR _ 3 )) ĊĠĠĠ Ġexpect ( clause . toString ()). toBe (""" Media . Media Rating ĠBETWEEN Ġ 0 ĠAND Ġ 6 0 """) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Will Accept () Ġ{ ĊĠĠĠ Ġexpect ( Rating Matcher . Is . will Accept ( Matcher Data ("", Ġ 1 0 1 , Ġ 0 ))). toBe ( false ) ĊĠĠĠ Ġexpect ( Rating Matcher . IsNot . will Accept ( Matcher Data ("", Ġ- 2 , Ġ 0 ))). toBe ( false ) ĊĠĠĠ Ġexpect ( Rating Matcher . Is GreaterThan . will Accept ( Matcher Data ("", Ġ 2 5 6 , Ġ 0 ))). toBe ( false ) ĊĠĠĠ Ġexpect ( Rating Matcher . Is LessThan . will Accept ( Matcher Data ("", Ġ 5 0 0 , Ġ 0 ))). toBe ( false ) ĊĠĠĠ Ġexpect ( Rating Matcher . IsIn The Range . will Accept ( Matcher Data ("", Ġ- 1 , Ġ 1 0 1 ))). toBe ( false ) ĊĠĠĠ Ġexpect ( Rating Matcher . IsIn The Range . will Accept ( Matcher Data ("", Ġ 0 , Ġ- 2 ))). toBe ( false ) ĊĠĠĠ Ġexpect ( Rating Matcher . IsIn The Range . will Accept ( Matcher Data ("", Ġ 1 0 0 , Ġ 1 0 ))). toBe ( false ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Find ById () Ġ{ ĊĠĠĠ Ġ// ĠIDs Ġshould Ġnever Ġchange ĊĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠ 1 Ġto ĠRating Matcher . Is , ĊĠĠĠĠĠĠ 2 Ġto ĠRating Matcher . IsNot , ĊĠĠĠĠĠĠ 3 Ġto ĠRating Matcher . Is GreaterThan , ĊĠĠĠĠĠĠ 4 Ġto ĠRating Matcher . Is LessThan , ĊĠĠĠĠĠĠ 5 Ġto ĠRating Matcher . IsIn The Range , ĊĠĠĠ Ġ). forEach Ġ{ Ġpair Ġ-> ĊĠĠĠĠĠ Ġexpect ( Rating Matcher . from Id ( pair . first )). toBe ( pair . second ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest All Values () Ġ{ ĊĠĠĠ ĠlistOf ( ĊĠĠĠĠĠ ĠRating Matcher . Is , ĊĠĠĠĠĠ ĠRating Matcher . IsNot , ĊĠĠĠĠĠ ĠRating Matcher . Is GreaterThan , ĊĠĠĠĠĠ ĠRating Matcher . Is LessThan , ĊĠĠĠĠĠ ĠRating Matcher . IsIn The Range , ĊĊĠĠĠĠĠ Ġ). let Ġ{ Ġlist Ġ-> ĊĠĠĠĠĠ Ġexpect ( Rating Matcher . ALL _ VALUES . size ). toBe ( list . size ) ĊĠĠĠĠĠ Ġlist . forEach Ġ{ Ġmatcher Ġ-> Ġexpect ( Rating Matcher . ALL _ VALUES ). toContain ( matcher ) Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ