package kz.arta.synergy.workflow.mobile.android;

import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.List;

import kz.arta.synergy.workflow.mobile.android.common.models.offline.OfflineComment;
import kz.arta.synergy.workflow.mobile.android.documents.offline.actions.DocumentAddCommentTable;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;

/**
 * Created by neox on 05.10.16.
 * Тесты ...
 */
@RunWith(AndroidJUnit4.class)
@LargeTest
public class DocumentAddCommentTableTest {

    private DocumentAddCommentTable db;

    @Before
    public void setUp(){
        db = new DocumentAddCommentTable(InstrumentationRegistry.getTargetContext());
        db.removeAll();
        db.add("1", "2", "3", "4", "5", "6");
        db.add("11", "22", "33", "44", "55", "66");
        db.add("111", "222", "333", "444", "555", "666");
    }

    @After
    public void finish() {
        db.close();
    }

    @Test
    public void testPreConditions() {
        assertNotNull(db);
    }

    @Test
    public void testGetByDocumentID() {
        List<OfflineComment> list =  db.getByDocumentID("11");
        assertNotNull(list);
        assertEquals(1, list.size());
    }

    @Test
    public void testGetAll() {
        List<OfflineComment> list =  db.get();
        assertNotNull(list);
        assertEquals(3, list.size());
    }

}
