This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
app/src/test/java/com/mgaetan89/showsrage/adapter/ComingEpisodesPagerAdapter_EmptyTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mgaetan89.showsrage.adapter; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ComingEpisodesPagerAdapter_EmptyTest { | ||
private ComingEpisodesPagerAdapter adapter; | ||
|
||
public ComingEpisodesPagerAdapter_EmptyTest() { | ||
} | ||
|
||
@Before | ||
public void before() { | ||
this.adapter = new ComingEpisodesPagerAdapter(null, null, null); | ||
} | ||
|
||
@Test | ||
public void getCount() { | ||
assertThat(this.adapter.getCount()).isEqualTo(0); | ||
} | ||
|
||
@After | ||
public void after() { | ||
this.adapter = null; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/test/java/com/mgaetan89/showsrage/adapter/EpisodePagerAdapter_EmptyTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.mgaetan89.showsrage.adapter; | ||
|
||
import android.support.v4.app.Fragment; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class EpisodePagerAdapter_EmptyTest { | ||
private EpisodePagerAdapter adapter; | ||
|
||
@Before | ||
public void before() { | ||
this.adapter = new EpisodePagerAdapter(null, mock(Fragment.class), null); | ||
} | ||
|
||
@Test | ||
public void getCount() { | ||
assertThat(this.adapter.getCount()).isEqualTo(0); | ||
} | ||
|
||
@After | ||
public void after() { | ||
this.adapter = null; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
app/src/test/java/com/mgaetan89/showsrage/adapter/ShowPagerAdapter_EmptyTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.mgaetan89.showsrage.adapter; | ||
|
||
import android.content.res.Resources; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentActivity; | ||
|
||
import com.mgaetan89.showsrage.EmptyFragmentHostCallback; | ||
import com.mgaetan89.showsrage.R; | ||
import com.mgaetan89.showsrage.fragment.ShowOverviewFragment; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class ShowPagerAdapter_EmptyTest { | ||
private ShowPagerAdapter adapter; | ||
|
||
@Before | ||
public void before() { | ||
FragmentActivity activity = mock(FragmentActivity.class); | ||
when(activity.getResources()).thenReturn(mock(Resources.class)); | ||
|
||
Fragment fragment = mock(Fragment.class); | ||
|
||
try { | ||
Field fragmentHostField = Fragment.class.getDeclaredField("mHost"); | ||
fragmentHostField.setAccessible(true); | ||
fragmentHostField.set(fragment, new EmptyFragmentHostCallback(activity)); | ||
} catch (IllegalAccessException ignored) { | ||
} catch (NoSuchFieldException ignored) { | ||
} | ||
|
||
when(fragment.getString(R.string.show)).thenReturn("Show"); | ||
|
||
this.adapter = new ShowPagerAdapter(null, fragment, null); | ||
} | ||
|
||
@Test | ||
public void getCount() { | ||
assertThat(this.adapter.getCount()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
public void getItem() { | ||
Fragment fragment = this.adapter.getItem(0); | ||
assertThat(fragment).isInstanceOf(ShowOverviewFragment.class); | ||
assertThat(fragment.getArguments()).isNull(); | ||
} | ||
|
||
@Test | ||
public void getPageTitle() { | ||
assertThat(this.adapter.getPageTitle(0)).isEqualTo("Show"); | ||
} | ||
|
||
@After | ||
public void after() { | ||
this.adapter = null; | ||
} | ||
} |