import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

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

// StockMonitor se prueba con dos test doubles: un stub que fija el stock y un spy
// que recuerda los avisos.
class StockMonitorTest {

    @Test
    void notifiesWhenStockIsBelowThreshold() {
        SpyNotifier spy = new SpyNotifier();
        StockMonitor monitor = new StockMonitor(new FixedStockLevels(2), spy, 5);

        monitor.check("arroz");

        assertEquals(List.of("Stock bajo: arroz (2)"), spy.sent());
    }

    @Test
    void staysQuietWhenStockIsEnough() {
        SpyNotifier spy = new SpyNotifier();
        StockMonitor monitor = new StockMonitor(new FixedStockLevels(5), spy, 5);

        monitor.check("arroz");

        assertTrue(spy.sent().isEmpty());
    }
}
