package ru.matevosyan.start;

import org.junit.Test;
import ru.matevosyan.models.Item;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;

/**
 * Class StartUITest created for testing.
 * Created on 07.12.2016.
 * @since 1.0
 * @version 1.0
 * @author Matevosyan Vardan
 */

public class StartUITest {
    @Test
    public void whenCreateItemThenSaveInTracker() {

        String[] answers = {

            "1", // select menu 1. add item
            "task 1", // items name
            "task desc", // items desc
            "n" // exit
        };

        Input stub = new StubInput(answers);
        Tracker tracker = new Tracker();

        new StartUI(stub, tracker).init();
        Item item = tracker.findByName("task 1");
        assertThat(item.getName(), is("task 1"));
    }
}
@@ -322,16 +322,17 @@
 ITest %7B%0A
+%0A
     @Tes
@@ -371,11 +371,17 @@
 Then
-Sav
+FindByNam
 eInT
@@ -663,17 +663,16 @@
 cker();%0A
-%0A
         
@@ -756,16 +756,17 @@
 sk 1%22);%0A
+%0A
         
@@ -812,10 +812,1689 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void whenCreateItemThenFindByIdTracker() %7B%0A%0A        String%5B%5D answer = %7B%0A                %221%22,%0A                %22task 2%22,%0A                %22task desc%22,%0A                %22n%22%0A        %7D;%0A%0A        Input stub = new StubInput(answer);%0A        Tracker tracker = new Tracker();%0A        new StartUI(stub, tracker).init();%0A%0A        for (Item item : tracker.getAll())%7B%0A            item = tracker.findById(item.getId());%0A%0A            assertThat(item, is(tracker.getAll()%5B0%5D));%0A        %7D%0A%0A%0A    %7D%0A%0A    @Test%0A    public void whenCreateItemThenFindByDateTracker() %7B%0A%0A        String%5B%5D answer = %7B%0A                %221%22,%0A                %22task 3%22,%0A                %22task desc%22,%0A                %22n%22%0A        %7D;%0A%0A        Input stub = new StubInput(answer);%0A        Tracker tracker = new Tracker();%0A        new StartUI(stub, tracker).init();%0A%0A        for (Item item : tracker.getAll())%7B%0A            item = tracker.findByDate(item.getCreate());%0A%0A            assertThat(item, is(tracker.getAll()%5B0%5D));%0A        %7D%0A%0A%0A    %7D%0A%0A    @Test%0A    public void whenCreateItemThenEditTracker() %7B%0A%0A        String id = %220%22;%0A        Tracker tracker = new Tracker();%0A%0A        for (Item item : tracker.getAll())%7B%0A            id = item.getId();%0A        %7D%0A%0A        String%5B%5D answer = %7B%0A                %221%22,%0A                %22task 3%22,%0A                %22task desc%22,%0A                %22y%22,%0A                %222%22,%0A                id,%0A                %22task 4%22,%0A                %22task desc%22,%0A                %22n%22%0A        %7D;%0A%0A        Input stub = new StubInput(answer);%0A        new StartUI(stub, tracker).init();%0A%0A        for (Item item : tracker.getAll())%7B%0A           assertThat(item.getName(), is(%22task 4%22));%0A        %7D%0A%0A%0A    %7D
 %0A%7D

add StartUITest.java