Last active
August 22, 2019 10:41
-
-
Save IvanShafran/fd8e1e1be54168cc486ef8ae03271435 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
public class ShowRateUsLogicTest { | |
// property declaration is skipped | |
@Before public void setUp() { | |
rateUsPreferences = new RateUsPreferencesMock(); | |
buyPreferences = new BuyPreferencesMock(); | |
time = new TimeMock(); | |
showRateUsLogic = new ShowRateUsLogic(rateUsPreferences, buyPreferences, time); | |
} | |
@Test public void onFirstCheckAndOneClickItShouldNotShow() { | |
buyPreferences.incrementBuyCount(); | |
Assert.assertFalse(showRateUsLogic.shouldShowRateUs()); | |
} | |
@Test public void onThreeClicksAndItShouldShow() { | |
// clicked three times | |
buyPreferences.incrementBuyCount(); | |
buyPreferences.incrementBuyCount(); | |
buyPreferences.incrementBuyCount(); | |
// set first dialog show time | |
final Calendar calendar = Calendar.getInstance(); | |
calendar.set(2019, Calendar.JULY, 7); | |
rateUsPreferences.setLastShownTimeMillis(calendar.getTimeInMillis()); | |
// set current time to be 90 days after first show | |
time.setCurrentTimeMillis(calendar.getTimeInMillis() + TimeUnit.DAYS.toMillis(90)); | |
Assert.assertTrue(showRateUsLogic.shouldShowRateUs()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment