package com.ibtp.kontor.tradingcards.dal;

import com.ibtp.kontor.dal.DatabaseManager;
import com.ibtp.kontor.util.LocalTestDatabase;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import com.ibtp.kontor.tradingcards.entity.PositionEntity;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Collection;

/**
 * Created by tpeetz on 27.01.2015.
 */
public class PositionImplTest {

    @BeforeAll
    public static void setUp() {
        DatabaseManager.setDatabase(new LocalTestDatabase());
    }

    @Test
    public void testPositionAddAndDelete() {
        String positionName = "testPositionAddAndDelete";
        PositionImpl positionImpl = new PositionImpl();
	    PositionEntity position = positionImpl.addPosition(positionName);
        Collection<PositionEntity> resultList = positionImpl.findByName(positionName);
        assertEquals(1, resultList.size());
        positionImpl.delete(position);
        resultList = positionImpl.findByName(positionName);
        assertEquals(0, resultList.size());
    }

    @Test
    public void testPositionFindAll() {
        PositionImpl positionImpl = new PositionImpl();
        Collection<PositionEntity> resultList = positionImpl.findAll();
        assertEquals(0, resultList.size());
    }
}

