package com.example.boidelov3;

import org.junit.Test;
import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.List;

/**
 * Tests unitaires pour la classe Question.
 * Couvre les getters/setters et les cas limites.
 */
public class QuestionTest {

    @Test
    public void testDefaultConstructor_createsEmptyQuestion() {
        Question question = new Question();

        assertEquals("ID should be 0 by default", 0, question.getId());
        assertNull("Question text should be null by default", question.getQuestion());
        assertEquals("Gorger should be 0 by default", 0, question.getGorger());
        assertFalse("Distribution should be false by default", question.isDistribution());
        assertFalse("Recois should be false by default", question.isRecois());
        assertFalse("Manches should be false by default", question.isManches());
        assertFalse("Caliente should be false by default", question.isCaliente());
        assertNull("Arret should be null by default", question.getArret());
        assertNull("Variante should be null by default", question.getVariante());
    }

    @Test
    public void testSetId_getId_returnsCorrectValue() {
        Question question = new Question();
        question.setId(42);

        assertEquals("ID should be 42", 42, question.getId());
    }

    @Test
    public void testSetQuestion_getQuestion_returnsCorrectValue() {
        Question question = new Question();
        String testQuestion = "Test question text";
        question.setQuestion(testQuestion);

        assertEquals("Question text should match", testQuestion, question.getQuestion());
    }

    @Test
    public void testSetGorger_getGorger_returnsCorrectValue() {
        Question question = new Question();
        question.setGorger(5);

        assertEquals("Gorger should be 5", 5, question.getGorger());
    }

    @Test
    public void testSetDistribution_isDistribution_returnsCorrectValue() {
        Question question = new Question();
        question.setDistribution(true);

        assertTrue("Distribution should be true", question.isDistribution());
    }

    @Test
    public void testSetRecois_isRecois_returnsCorrectValue() {
        Question question = new Question();
        question.setRecois(true);

        assertTrue("Recois should be true", question.isRecois());
    }

    @Test
    public void testSetManches_isManches_returnsCorrectValue() {
        Question question = new Question();
        question.setManches(true);

        assertTrue("Manches should be true", question.isManches());
    }

    @Test
    public void testSetCaliente_isCaliente_returnsCorrectValue() {
        Question question = new Question();
        question.setCaliente(true);

        assertTrue("Caliente should be true", question.isCaliente());
    }

    @Test
    public void testSetArret_getArret_returnsCorrectValue() {
        Question question = new Question();
        String arretText = "Arrêtez maintenant !";
        question.setArret(arretText);

        assertEquals("Arret text should match", arretText, question.getArret());
    }

    @Test
    public void testSetManchesRestantes_getManchesRestantes_returnsCorrectValue() {
        Question question = new Question();
        question.setManchesRestantes(10);

        assertEquals("ManchesRestantes should be 10", 10, question.getManchesRestantes());
    }

    @Test
    public void testSetArretMessage_getArretMessage_returnsCorrectValue() {
        Question question = new Question();
        String message = "Fin du défi !";
        question.setArretMessage(message);

        assertEquals("ArretMessage should match", message, question.getArretMessage());
    }

    @Test
    public void testSetArretMessageManche_getArretMessageManche_returnsCorrectValue() {
        Question question = new Question();
        String message = "Fin de défi\nArrêtez maintenant !";
        question.setArretMessageManche(message);

        assertEquals("ArretMessageManche should match", message, question.getArretMessageManche());
    }

    @Test
    public void testSetVariante_getVariante_returnsCorrectValue() {
        Question question = new Question();
        List<String> variantes = Arrays.asList("Variante 1", "Variante 2", "Variante 3");
        question.setVariante(variantes);

        assertEquals("Variante list should match", variantes, question.getVariante());
        assertEquals("Variante list size should be 3", 3, question.getVariante().size());
    }

    @Test
    public void testSetVariante_withEmptyList_returnsEmptyList() {
        Question question = new Question();
        List<String> emptyList = Arrays.asList();
        question.setVariante(emptyList);

        assertNotNull("Variante should not be null", question.getVariante());
        assertTrue("Variante list should be empty", question.getVariante().isEmpty());
    }

    @Test
    public void testSetVariante_withNull_acceptsNull() {
        Question question = new Question();
        question.setVariante(null);

        assertNull("Variante should be null", question.getVariante());
    }

    @Test
    public void testCompleteQuestion_withAllFields() {
        Question question = new Question();
        question.setId(100);
        question.setQuestion("Question complète");
        question.setGorger(3);
        question.setDistribution(true);
        question.setRecois(false);
        question.setManches(true);
        question.setCaliente(false);
        question.setArret("Stop !");
        question.setManchesRestantes(5);
        question.setArretMessage("Message");
        question.setArretMessageManche("Message manche");
        question.setVariante(Arrays.asList("V1", "V2"));

        assertEquals("ID should be 100", 100, question.getId());
        assertEquals("Question should match", "Question complète", question.getQuestion());
        assertEquals("Gorger should be 3", 3, question.getGorger());
        assertTrue("Distribution should be true", question.isDistribution());
        assertFalse("Recois should be false", question.isRecois());
        assertTrue("Manches should be true", question.isManches());
        assertFalse("Caliente should be false", question.isCaliente());
        assertEquals("Arret should match", "Stop !", question.getArret());
        assertEquals("ManchesRestantes should be 5", 5, question.getManchesRestantes());
        assertEquals("ArretMessage should match", "Message", question.getArretMessage());
        assertEquals("ArretMessageManche should match", "Message manche", question.getArretMessageManche());
        assertEquals("Variante size should be 2", 2, question.getVariante().size());
    }

    @Test
    public void testQuestionWithZeroGorger() {
        Question question = new Question();
        question.setGorger(0);

        assertEquals("Gorger should be 0", 0, question.getGorger());
    }

    @Test
    public void testQuestionWithNegativeManchesRestantes() {
        Question question = new Question();
        question.setManchesRestantes(-1);

        assertEquals("ManchesRestantes should be -1", -1, question.getManchesRestantes());
    }

    @Test
    public void testQuestionWithLargeId() {
        Question question = new Question();
        int largeId = 999999;
        question.setId(largeId);

        assertEquals("ID should handle large values", largeId, question.getId());
    }

    @Test
    public void testMultipleSetters_chainingWorks() {
        Question question = new Question();
        question.setId(1);
        question.setQuestion("Test");
        question.setGorger(2);
        question.setDistribution(true);

        assertEquals("All setters should work independently", 1, question.getId());
        assertEquals("Question should be preserved", "Test", question.getQuestion());
        assertEquals("Gorger should be preserved", 2, question.getGorger());
        assertTrue("Distribution should be preserved", question.isDistribution());
    }
}
