package shop.backend;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;

import static org.junit.jupiter.api.Assertions.*;

class OnlineShopTest {
    private OnlineShop onlineShop;
    @BeforeEach
    public void setUp() {
        onlineShop  = new OnlineShop();
        ArrayList<String> lines = new ArrayList<>();
        lines.add("ID,Name,Gewicht,Nettopreis,MwSt,Lagerbestand");
        lines.add("1,Product 1,1.0,10.0,19.0,100");
        lines.add("2,Product 2,2.0,20.0,7.0,50");
        onlineShop.loadProductsAndParse(lines);
    }

    @Test
    public void testGetProdId() {
        Product product = onlineShop.getProdId(1);
        assertNotNull(product);
        assertEquals("Product 1", product.getName());

        Product notFound = onlineShop.getProdId(99);
        assertNull(notFound);
    }


}