package thb.jeanluc.adventure.command.impl;

import org.junit.jupiter.api.Test;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

class GoCommandTest {

    @Test
    void execute_validDirection_movesPlayer() {
        CommandTestSupport.World w = new CommandTestSupport.World();

        new GoCommand().execute(w.ctx, List.of("north"));

        assertThat(w.player.getCurrentRoom()).isEqualTo(w.hallway);
    }

    @Test
    void execute_noExit_complains() {
        CommandTestSupport.World w = new CommandTestSupport.World();

        new GoCommand().execute(w.ctx, List.of("south"));

        assertThat(w.player.getCurrentRoom()).isEqualTo(w.kitchen);
        assertThat(w.io.allOutput()).contains("can't go south");
    }

    @Test
    void execute_unknownDirection_complains() {
        CommandTestSupport.World w = new CommandTestSupport.World();

        new GoCommand().execute(w.ctx, List.of("upwards"));

        assertThat(w.player.getCurrentRoom()).isEqualTo(w.kitchen);
        assertThat(w.io.allOutput()).contains("upwards");
    }

    @Test
    void execute_noArg_complains() {
        CommandTestSupport.World w = new CommandTestSupport.World();

        new GoCommand().execute(w.ctx, List.of());

        assertThat(w.io.allOutput()).contains("Go where");
    }
}
