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

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

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

        assertThat(w.player.hasItem("lamp")).isTrue();
        assertThat(w.kitchen.findItem("lamp")).isEmpty();
    }

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

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

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

        assertThat(w.player.hasItem("lamp")).isFalse();
        assertThat(w.kitchen.findItem("lamp")).isPresent();
    }

    @Test
    void drop_notInInventory_complains() {
        CommandTestSupport.World w = new CommandTestSupport.World();
        new DropCommand().execute(w.ctx, List.of("lamp"));
        assertThat(w.io.allOutput()).contains("not carrying");
    }
}
