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

    @Test
    void use_readableInInventory_writesText() {
        CommandTestSupport.World w = new CommandTestSupport.World();
        new TakeCommand().execute(w.ctx, List.of("letter"));

        new UseCommand().execute(w.ctx, List.of("letter"));

        assertThat(w.io.lastOutput()).isEqualTo("dear reader");
    }

    @Test
    void use_unknownItem_complains() {
        CommandTestSupport.World w = new CommandTestSupport.World();
        new UseCommand().execute(w.ctx, List.of("dragon"));
        assertThat(w.io.allOutput()).contains("no 'dragon'");
    }

    @Test
    void read_nonReadable_complains() {
        CommandTestSupport.World w = new CommandTestSupport.World();
        new TakeCommand().execute(w.ctx, List.of("lamp"));

        new ReadCommand().execute(w.ctx, List.of("lamp"));

        assertThat(w.io.lastOutput()).contains("nothing to read");
    }

    @Test
    void examine_item_writesDescription() {
        CommandTestSupport.World w = new CommandTestSupport.World();
        new ExamineCommand().execute(w.ctx, List.of("letter"));
        assertThat(w.io.lastOutput()).isEqualTo("a letter");
    }

    @Test
    void examine_npc_writesDescription() {
        CommandTestSupport.World w = new CommandTestSupport.World();
        new ExamineCommand().execute(w.ctx, List.of("old_man"));
        assertThat(w.io.lastOutput()).isEqualTo("stooped");
    }
}
