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.SportEntity;

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

import java.util.Collection;
import java.util.List;

/**
 * Created by TPEETZ on 19.01.2015.
 */
public class SportImplTest {

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

    @Test
    public void testSportAddAndDelete() {
        String sportName = "testSportAddAndDelete";
        SportImpl sportImpl = new SportImpl();
        SportEntity sport = sportImpl.addSport(sportName);
        List<SportEntity> sportList = sportImpl.findByName(sportName);
        assertEquals(1, sportList.size());
        sportImpl.delete(sport);
        List<SportEntity> result = sportImpl.findByName(sportName);
        assertEquals(0, result.size());
    }

    @Test
    public void testSportFindAll() {
        SportImpl sportImpl = new SportImpl();
        Collection<SportEntity> resultList = sportImpl.findAll();
        assertEquals(0, resultList.size());
    }
}
