Last active
August 22, 2019 10:40
-
-
Save IvanShafran/6d52c932106b6ef6fa84830af4631e40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShowRateUsLogicTest { | |
// property declaration and setup are skipped | |
private fun prepareConditions( | |
buyClickedTimes: Int = 0, | |
isNeverShownAgainClicked: Boolean = false, | |
isRateNowClicked: Boolean = false, | |
lastShownTimeMillis: Long = 0, | |
currentTimeMillis: Long = 0 | |
) { | |
repeat(buyClickedTimes) { buyPreferences.incrementBuyCount() } | |
if (isNeverShownAgainClicked) rateUsPreferences.setNeverShownAgainClicked() | |
if (isRateNowClicked) rateUsPreferences.setRateNowClickedClicked() | |
rateUsPreferences.setLastShownTimeMillis(lastShownTimeMillis) | |
whenever(time.getCurrentTimeMillis()).thenReturn(currentTimeMillis) | |
} | |
@Test fun onFirstCheckAndOneClickItShouldNotShow() { | |
prepareConditions(buyClickedTimes = 1) | |
Assert.assertFalse(showRateUsLogic.shouldShowRateUs()) | |
} | |
@Test fun onThreeClicksAndItShouldShow() { | |
prepareConditions( | |
buyClickedTimes = 3, | |
lastShownTimeMillis = SOME_DAY_IN_MILLIS, | |
currentTimeMillis = SOME_DAY_IN_MILLIS + MORE_THAN_TWO_MONTHS | |
) | |
Assert.assertTrue(showRateUsLogic.shouldShowRateUs()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment