|
1 | | -package com.d4rk.androidtutorials.java.data.source; |
| 1 | +package com.d4rk.androidtutorials.java.data.source.local; |
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertEquals; |
4 | 4 | import static org.mockito.Mockito.mock; |
|
8 | 8 | import android.content.res.Resources; |
9 | 9 |
|
10 | 10 | import com.d4rk.androidtutorials.java.R; |
| 11 | +import com.d4rk.androidtutorials.java.data.source.DefaultHomeLocalDataSource; |
11 | 12 |
|
12 | 13 | import org.junit.Test; |
13 | 14 |
|
14 | 15 | public class DefaultHomeLocalDataSourceTest { |
15 | 16 |
|
| 17 | + private static final String PLAY_STORE_BASE_URL = "https://play.google.com/store/apps/details?id="; |
| 18 | + |
| 19 | + @Test |
| 20 | + public void getPlayStoreUrl_returnsBaseUrl() { |
| 21 | + DefaultHomeLocalDataSource dataSource = |
| 22 | + new DefaultHomeLocalDataSource(mockContextWithTips(new String[]{"tip"})); |
| 23 | + |
| 24 | + assertEquals(PLAY_STORE_BASE_URL, dataSource.getPlayStoreUrl()); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void getAppPlayStoreUrl_appendsPackageName() { |
| 29 | + DefaultHomeLocalDataSource dataSource = |
| 30 | + new DefaultHomeLocalDataSource(mockContextWithTips(new String[]{"tip"})); |
| 31 | + |
| 32 | + assertEquals(PLAY_STORE_BASE_URL + "com.example.app", |
| 33 | + dataSource.getAppPlayStoreUrl("com.example.app")); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void getAppPlayStoreUrl_allowsEmptyPackageName() { |
| 38 | + DefaultHomeLocalDataSource dataSource = |
| 39 | + new DefaultHomeLocalDataSource(mockContextWithTips(new String[]{"tip"})); |
| 40 | + |
| 41 | + assertEquals(PLAY_STORE_BASE_URL, dataSource.getAppPlayStoreUrl("")); |
| 42 | + } |
| 43 | + |
16 | 44 | @Test |
17 | | - public void playStoreUrlsFormattedCorrectly() { |
| 45 | + public void getAppPlayStoreUrl_handlesNullPackageName() { |
18 | 46 | DefaultHomeLocalDataSource dataSource = |
19 | 47 | new DefaultHomeLocalDataSource(mockContextWithTips(new String[]{"tip"})); |
20 | | - assertEquals("https://play.google.com/store/apps/details?id=com.d4rk.androidtutorials", dataSource.getPlayStoreUrl()); |
21 | | - assertEquals("https://play.google.com/store/apps/details?id=pkg", dataSource.getAppPlayStoreUrl("pkg")); |
| 48 | + |
| 49 | + assertEquals(PLAY_STORE_BASE_URL, dataSource.getAppPlayStoreUrl(null)); |
22 | 50 | } |
23 | 51 |
|
24 | 52 | @Test |
|
0 commit comments