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 RecipesTest {

    private Recipes object;

    private String code;
    private String title;
    private String description;
    private String time;
    private String rations;
    private String image;
    private String categoryID;
    private String category;

    @Before
    public void setUp() {
        object = mock(Recipes.class);

        code = "1";
        title = "Recepta 1";
        description = "Descripció recepta 1";
        time = "10 minuts";
        rations = "1 persones";
        image = "recipe_01.jpg";
        categoryID = "1";
        category = "Categoria 1";

        object = new Recipes(code,title,description,time,rations,image,categoryID,category);
    }

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

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

    @Test
    //Comprova que s'obte el valor esperat
    public void getTitle() {
        assertEquals(title,object.getTitle());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setTitle() {
        String newValue = "Recepta 2";
        object.setTitle(newValue);
        assertEquals(newValue,object.getTitle());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getDescription() {
        assertEquals(description,object.getDescription());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setDescription() {
        String newValue = "Descripció ecepta 2";
        object.setDescription(newValue);
        assertEquals(newValue,object.getDescription());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getTime() {
        assertEquals(time,object.getTime());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setTime() {
        String newValue = "20 minuts";
        object.setTime(newValue);
        assertEquals(newValue,object.getTime());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getRations() {
        assertEquals(rations,object.getRations());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setRations() {
        String newValue = "2 persones";
        object.setRations(newValue);
        assertEquals(newValue,object.getRations());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getImage() {
        assertEquals(image,object.getImage());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setImage() {
        String newValue = "recipe_02.jpg";
        object.setImage(newValue);
        assertEquals(newValue,object.getImage());
    }

    @Test
    //Comprova que s'obte el valor esperat
    public void getCategory() {
        assertEquals(category,object.getCategory());
    }

    @Test
    //Comprova que es pot modificar correctament el valor i retorna un String
    public void setCategory() {
        String newValue = "Categoria 2";
        object.setCategory(newValue);
        assertEquals(newValue,object.getCategory());
    }

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

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