Permalink
Browse files

Inner loop - Red: Test activity has recycler view

1 parent c22ab01 commit 8d6122f71067f9d8c12f70f3fbdade2a6b707d58 @CarlosMChica committed May 2, 2016
@@ -0,0 +1,40 @@
+package me.panavtec.androidbankkata;
+
+import android.content.Intent;
+import android.support.test.rule.ActivityTestRule;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static android.support.v7.widget.LinearLayoutManager.VERTICAL;
+import static me.panavtec.androidbankkata.R.id.recyclerView;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+
+public class ShowStatementActivityShould {
+
+ @Rule public ActivityTestRule<ShowStatementActivity> rule =
+ new ActivityTestRule<>(ShowStatementActivity.class, true, false);
+
+ @Test public void have_a_list_with_vertical_orientation() {
+ whenLaunchActivity();
+
+ assertThat(recyclerView(), instanceOf(RecyclerView.class));
+ assertThat(layoutManager(), instanceOf(LinearLayoutManager.class));
+ assertThat(layoutManager().getOrientation(), is(VERTICAL));
+ }
+
+ private LinearLayoutManager layoutManager() {
+ return (LinearLayoutManager) recyclerView().getLayoutManager();
+ }
+
+ private RecyclerView recyclerView() {
+ return (RecyclerView) rule.getActivity().findViewById(recyclerView);
+ }
+
+ private void whenLaunchActivity() {
+ rule.launchActivity(new Intent());
+ }
+}

0 comments on commit 8d6122f

Please sign in to comment.