package cn.six.robolectric.inject;


import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.util.ActivityController;

import cn.six.espresso.aut.BuildConfig;

import static junit.framework.Assert.assertEquals;

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
public class LifeInjectActivityTest {
    @Mock
    ILifePresenter presenter;
    private LifeInjectActivity actv;
    private ActivityController<LifeInjectActivity> actvController;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        actvController = Robolectric.buildActivity(LifeInjectActivity.class);
        actv = actvController.get();
    }

    @Test
    public void testNoInject_everythingIsNormal() {
        assertEquals(null, actv.stage);

        actvController.create();
        assertEquals("refresh: presenter name", actv.stage);

    }

    @Test
    public void testLifeInjectIsSuccessful() {
        actv.setPresenter(presenter);

        actvController.create();
    }
}

@@ -115,33 +115,8 @@
 th;%0A
-import org.mockito.Mock;%0A
 impo
@@ -150,16 +150,16 @@
 ations;%0A
+
 import o
@@ -545,48 +545,8 @@
 t %7B%0A
-    @Mock%0A    ILifePresenter presenter;%0A
     
@@ -646,16 +646,321 @@
 oller;%0A%0A
+    private ILifePresenter presenter = new ILifePresenter() %7B%0A        private ILifeView view;%0A%0A        @Override%0A        public void setView(ILifeView view) %7B%0A            this.view = view;%0A        %7D%0A%0A        @Override%0A        public void getName() %7B%0A            view.refresh(%22FakeOne%22);%0A        %7D%0A    %7D;%0A%0A
     @Bef
@@ -1431,24 +1431,57 @@
 cessful() %7B%0A
+        presenter.setView(actv);%0A
         actv
@@ -1503,24 +1503,24 @@
 resenter);%0A%0A
-
         actv
@@ -1536,20 +1536,74 @@
 r.create();%0A
+        assertEquals(%22refresh: FakeOne%22, actv.stage);%0A
     %7D%0A%7D%0A

add test for injection of presenter