package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;

import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.Test;

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

class GathererTest {

    @Test
    void testToString() {
        Gatherer g = new Gatherer(1);
        String s = g.toString();

        assertNotNull(s);
        assertTrue(s.contains(CharacterType.GATHERER.toString()));
    }

    @Test
    void testClone() {
        Gatherer g = new Gatherer(1, 3);
        Gatherer clone = (Gatherer) g.clone();

        assertNotNull(clone);
        assertEquals(g.getEra(), clone.getEra());
        assertEquals(g.getNMin(), clone.getNMin());
        assertNotSame(g, clone);
        assertEquals(g.getType(), clone.getType());
    }

    @Test
    void insert() {
        Player p = new Player("test");
        Gatherer g = new Gatherer(1);

        assertEquals(0, p.gatherers.size());

        g.insert(p);

        assertEquals(1, p.gatherers.size());
        assertTrue(p.gatherers.contains(g));

        Gatherer g2 = new Gatherer(1);
        g2.insert(p);

        assertEquals(2, p.gatherers.size());
        assertTrue(p.gatherers.contains(g2));
    }

    @Test
    void constructorTest() {
        Gatherer g = new Gatherer(1);

        assertEquals(1, g.getEra());
        assertEquals(CharacterType.GATHERER, g.getType());
        assertEquals(0, g.getNMin());
        assertFalse(g.IsEventCard());
    }

    @Test
    void constructorWithNMinTest() {
        Gatherer g = new Gatherer(1, 3);

        assertEquals(1, g.getEra());
        assertEquals(CharacterType.GATHERER, g.getType());
        assertEquals(3, g.getNMin());
        assertFalse(g.IsEventCard());
    }
}