package it.polimi.ingsw.gc14.Model.Orders;

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

import java.util.ArrayList;

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

class Order2Test {

    @Test
    void effect() {
        Player p1 = new Player("p1");
        Player p2 = new Player("p2");
        Player p3 = new Player("p3");

        Order2 order = new Order2(new ArrayList<>());

        order.push(p1);
        assertEquals(1, p1.getFoodValue());
        assertEquals(0, p2.getPrestigeValue());

        p2.addFood(1);
        order.push(p2);
        assertEquals(1, p1.getFoodValue());
        assertEquals(0, p1.getPrestigeValue());


        Order2 order2 = new Order2(new ArrayList<>());
        order2.push(new  Player("Test"));
        order2.push(p3);
        assertEquals(0, p3.getFoodValue());
        assertEquals(0, p3.getPrestigeValue());

        Order2 order3 = new Order2(new ArrayList<>());
        assertThrows(IndexOutOfBoundsException.class, () -> order3.effect(p1, 2));
        Order2 order4 = new Order2(new ArrayList<>());
        assertThrows(IndexOutOfBoundsException.class, () -> order4.effect(p1, -1));
    }
}