package sleepyweasel.purplefluffernutter;

import android.widget.Button;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;

import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class)
public class EditMovieActivityTest {

    @Test
    public void shouldOnClickSaveButtonAddMovieToContentProvider() throws Exception {
        EditMovieActivity activity = Robolectric.setupActivity(EditMovieActivity.class);
        Button saveButton = (Button) activity.findViewById(R.id.button_save);
        MovieContentProvider contentProvider = MovieContentProvider.getInstance();
        contentProvider.clear();

        saveButton.performClick();

        assertThat(contentProvider.isEmpty()).isFalse();
    }

    //TODO: shouldNotSaveAMovieWithoutATitle
}

@@ -65,16 +65,48 @@
 .Button;
+%0Aimport android.widget.TextView;
 %0A%0Aimport
@@ -286,16 +286,80 @@
 onfig;%0A%0A
+import butterknife.ButterKnife;%0Aimport butterknife.InjectView;%0A%0A
 import s
@@ -564,96 +564,150 @@
    @
-Test%0A    public void shouldOnClickSaveButtonAddMovieToContentProvider() throws Exception
+InjectView(R.id.button_save) Button saveButton;%0A%0A    @InjectView(R.id.movie_title_value) TextView movieTitleTextView;%0A%0A    void initActivity()
  %7B%0A 
@@ -810,73 +810,99 @@
 Butt
-on saveButton = (Button) activity.findViewById(R.id.button_save);
+erKnife.inject(this, activity);%0A    %7D%0A%0A    MovieContentProvider getEmptyContentProvider() %7B
 %0A   
@@ -1018,99 +1018,517 @@
 ();%0A
-%0A        saveButton.performClick();%0A%0A        assertThat(contentProvider.isEmpty()).isFalse(
+        return contentProvider;%0A    %7D%0A%0A    @Test%0A    public void shouldOnClickSaveButtonAddMovieToContentProvider() throws Exception %7B%0A        initActivity();%0A        String movieTitle = movieTitleTextView.getText().toString();%0A        MovieContentProvider contentProvider = getEmptyContentProvider();%0A%0A        saveButton.performClick();%0A%0A        assertThat(contentProvider.size()).isEqualTo(1);%0A        MovieEntry entry = contentProvider.getEntry(0);%0A        assertThat(entry.getTitle()).isEqualTo(movieTitle
 );%0A 

Enhance test for adding movie on save