package com.ibtp.kontor.tradingcards.dal;

import com.ibtp.kontor.dal.DatabaseManager;
import com.ibtp.kontor.util.LocalTestDatabase;
import com.ibtp.kontor.tradingcards.entity.TeamEntity;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.util.Collection;

/**
 * Created by tpeetz on 20.01.2015.
 */
public class TeamImplTest {

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

    @Test
    public void testTeamAddAndDelete() {
        String teamName = "testTeamAddAndDelete";
        TeamEntity team = new TeamEntity(teamName);
        TeamImpl teamImpl = new TeamImpl();
        teamImpl.store(team);
        Collection<TeamEntity> resultList = teamImpl.findByName(teamName);
        Assert.assertEquals(1, resultList.size());
        teamImpl.delete(team);
        resultList = teamImpl.findByName(teamName);
        Assert.assertEquals(0, resultList.size());
    }

    @Test
    public void testTeamFindAll() {
        TeamImpl teamImpl = new TeamImpl();
        Collection<TeamEntity> resultList = teamImpl.findAll();
        Assert.assertEquals(0, resultList.size());
    }
}
