package ca.six.todo.addedittask;


import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import ca.six.todo.data.source.TasksDataSource;

public class AddEditTaskPresenterTest {
    @Mock AddEditTaskContract.View view;
    @Mock TasksDataSource repo;

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


    // AddEditTaskPresenter presenter = new AddEditTaskPresenter(null, repo, view, true);
    @Test
    public void start() throws Exception {
        AddEditTaskPresenter presenter = new AddEditTaskPresenter(null, repo, view, true);

    }

    @Test
    public void saveTask() throws Exception {

    }

    @Test
    public void populateTask() throws Exception {

    }

    @Test
    public void onTaskLoaded() throws Exception {

    }

    @Test
    public void onDataNotAvailable() throws Exception {

    }

    @Test
    public void isDataMissing() throws Exception {

    }

}

/*
Issue01. init repo need a Context!
: mock a repo! (even the data is already a mock version)

Issue02. test all the public methods?
: No. start() method is an example


*/
@@ -1,8 +1,9 @@
+%0A
 package 
@@ -28,17 +28,16 @@
 ttask;%0A%0A
-%0A
 import o
@@ -164,35 +164,171 @@
 odo.
-data.source.TasksDataSource
+Injection;%0Aimport ca.six.todo.data.Task;%0Aimport ca.six.todo.data.source.TasksDataSource;%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.verify
 ;%0A%0Ap
@@ -440,16 +440,125 @@
  repo;%0A%0A
+    public static final String TITLE = %22title%22;%0A    public static final String DESCRIPTION = %22description%22;%0A%0A
     @Bef
@@ -646,10 +646,83 @@
     
-//
+@Test%0A    public void createTask_showEmptyView() throws Exception %7B%0A       
  Add
@@ -809,56 +809,190 @@
     
-@Test%0A    public void start() throws Exception %7B
+    // do nothing. so it's not testable%0A    %7D%0A%0A    @Test%0A    public void createAndSaveEmptyTask_showError() throws Exception %7B%0A        // taskId is null, so it is creating a new task
 %0A   
@@ -1083,114 +1083,156 @@
 e);%0A
-%0A
     
-%7D%0A%0A
     
-@Test%0A    public void saveTask() throws Exception %7B%0A%0A    %7D%0A%0A    @Test%0A    public void populate
+presenter.saveTask(%22%22, %22%22);%0A%0A        verify(view).showEmptyTaskError();%0A    %7D%0A%0A    @Test%0A    public void createAndSaveTask_returnBackWithNew
 Task
@@ -1257,219 +1257,328 @@
 n %7B%0A
-%0A
     
-%7D%0A%0A
     
-@Test%0A    public void onTaskLoaded() throws Exception %7B%0A
+// taskId is null, so it is creating a new task
 %0A    
-%7D%0A%0A
     
-@Test%0A    public void onDataNotAvailable() throws Exception %7B
+AddEditTaskPresenter presenter = new AddEditTaskPresenter(null, repo, view, true);%0A        presenter.saveTask(TITLE, DESCRIPTION);
 %0A%0A    
-%7D%0A%0A
     
-@Test%0A    public void isDataMissing() throws Exception %7B%0A
+Task task = new Task(TITLE, DESCRIPTION);%0A        verify(repo).saveTask(task);%0A        verify(view).showTasksList();
 %0A   
@@ -1758,7 +1758,297 @@
 le%0A%0A
+Issue03. why mock TaskRepo, not TaskSource in the sample?%0A:%0A%0AIssue04: create new task failed in the test:%0A        Task task = new Task(TITLE, DESCRIPTION);%0A        verify(repo).saveTask(task)%0A: Erro Info : %22Argument(s) are different%22. Because the ID is different!%0AThen how to solve it?%0A: %0A
 %0A*/
+%0A

write unit test code