import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.List;
import org.junit.jupiter.api.Test;

class PriceReaderTest {

    @Test
    void readsValidLines() throws InvalidPriceException {
        List<Money> prices = PriceReader.read(List.of("A-01;3.50", "A-02;12.00"));
        assertEquals(List.of(new Money(350, "PEN"), new Money(1200, "PEN")), prices);
    }

    @Test
    void badPriceKeepsLineAndCause() {
        InvalidPriceException e = assertThrows(InvalidPriceException.class,
                () -> PriceReader.read(List.of("A-01;3.50", "A-02;doce")));
        assertEquals(2, e.line());
        assertEquals("línea 2: precio inválido \"doce\"", e.getMessage());
        assertInstanceOf(NumberFormatException.class, e.getCause());
    }
}
