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.OfflineAttachment;
import kz.arta.synergy.workflow.mobile.android.documents.offline.actions.DocumentAddAttachmentTable;

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

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

    private DocumentAddAttachmentTable db;

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

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

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

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

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

}