package edu.uoc.prezmm.a1list2cook.objects_class;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;

public class IngredientsTest {

    private Ingredients object1,object2;

    private String code;
    private String name;
    private String quantity;
    private String stat;

    @Before
    public void setUp() {
        object1 = mock(Ingredients.class);
        object2 = mock(Ingredients.class);

        code = "1";
        name = "Ingredient 1";
        quantity = "1 unitat";
        stat = "1";

        object1 = new Ingredients(code,name,quantity);
        object2 = new Ingredients(code,name,quantity,stat);
    }

    @Test
    //Comprova que s'obte el valor esperat del tipus int
    public void getCode() {
        assertEquals(Integer.parseInt(code),object1.getCode());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un int
    public void setCode() {
        int newValue = 2;
        object1.setCode(newValue);
        assertEquals(newValue,object1.getCode());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getName() {
        assertEquals(name,object1.getName());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setName() {
        String newValue = "Ingredient 2";
        object1.setName(newValue);
        assertEquals(newValue,object1.getName());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getQuantity() {
        assertEquals(quantity,object1.getQuantity());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setQuantity() {
        String newValue = "2 unitats";
        object1.setQuantity(newValue);
        assertEquals(newValue,object1.getQuantity());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getStat() {
        assertEquals(stat,object2.getStat());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setStat() {
        String newValue = "0";
        object1.setStat(newValue);
        assertEquals(newValue,object1.getStat());
    }
}