package Ġcom . m ga et an 8 9 . show sr age . extension . preferences Ċ Ċ import Ġandroid . content . SharedPreferences Ċ import Ġandroid . support . test . Instrumentation Registry Ċ import Ġandroid . support . test . rule . Activity Test Rule Ċ import Ġandroid . support . test . runner . Android JUnit 4 Ċ import Ġcom . m ga et an 8 9 . show sr age . Constants Ċ import Ġcom . m ga et an 8 9 . show sr age . Test Activity Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . Fields Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . get LogLevel Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . get Preferences Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . save LogLevel Ċ import Ġcom . m ga et an 8 9 . show sr age . model . LogLevel Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠSharedPreferences Extension _ Get LogLevel Test Ġ{ Ċ ĉ @ Jvm Field Ċ ĉ @ Rule Ċ ĉ val Ġactivity Rule Ġ= ĠActivity Test Rule ( Test Activity :: class . java , Ġfalse , Ġfalse ) ĊĊ ĉ private Ġlateinit Ġvar Ġpreference : ĠSharedPreferences ĊĊ ĉ @ Before Ċ ĉ fun Ġbefore () Ġ{ Ċĉ ĉ this . preference Ġ= ĠInstrument ation Registry . getTarget Context (). get Preferences () Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġget LogLevel _ Debug () Ġ{ Ċĉ ĉ this . preference . save LogLevel ( LogLevel . DEBUG ) ĊĊĉ ĉ val Ġlog Level Ġ= Ġthis . preference . get LogLevel () ĊĊĉ ĉ assertThat ( logLevel ). isEqualTo ( LogLevel . DEBUG ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġget LogLevel _ Empty () Ġ{ Ċĉ ĉ this . preference . edit (). putString ( Fields . LOG S _ LEVEL . field , Ġ""). apply () ĊĊĉ ĉ val Ġlog Level Ġ= Ġthis . preference . get LogLevel () ĊĊĉ ĉ assertThat ( logLevel ). isEqualTo ( Constants . Defaults . LOG _ LEVEL ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġget LogLevel _ Error () Ġ{ Ċĉ ĉ this . preference . save LogLevel ( LogLevel . ERROR ) ĊĊĉ ĉ val Ġlog Level Ġ= Ġthis . preference . get LogLevel () ĊĊĉ ĉ assertThat ( logLevel ). isEqualTo ( LogLevel . ERROR ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġget LogLevel _ Info () Ġ{ Ċĉ ĉ this . preference . save LogLevel ( LogLevel . INFO ) ĊĊĉ ĉ val Ġlog Level Ġ= Ġthis . preference . get LogLevel () ĊĊĉ ĉ assertThat ( logLevel ). isEqualTo ( LogLevel . INFO ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġget LogLevel _ Missing () Ġ{ Ċĉ ĉ assertThat ( this . preference . contains ( Fields . LOG S _ LEVEL . field )). isFalse () ĊĊĉ ĉ val Ġlog Level Ġ= Ġthis . preference . get LogLevel () ĊĊĉ ĉ assertThat ( logLevel ). isEqualTo ( Constants . Defaults . LOG _ LEVEL ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġget LogLevel _ Null () Ġ{ Ċĉ ĉ this . preference . edit (). putString ( Fields . LOG S _ LEVEL . field , Ġnull ). apply () ĊĊĉ ĉ val Ġlog Level Ġ= Ġthis . preference . get LogLevel () ĊĊĉ ĉ assertThat ( logLevel ). isEqualTo ( Constants . Defaults . LOG _ LEVEL ) Ċ ĉ } ĊĊ ĉ @ Test Ċ ĉ fun Ġget LogLevel _ Warning () Ġ{ Ċĉ ĉ this . preference . save LogLevel ( LogLevel . WARNING ) ĊĊĉ ĉ val Ġlog Level Ġ= Ġthis . preference . get LogLevel () ĊĊĉ ĉ assertThat ( logLevel ). isEqualTo ( LogLevel . WARNING ) Ċ ĉ } ĊĊ ĉ @ After Ċ ĉ fun Ġafter () Ġ{ Ċĉ ĉ this . preference . edit (). clear (). apply () Ċ ĉ } Ċ } Ċ