diff --git a/README.md b/README.md index 72f9fb6..637c1b7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,5 @@ Shop Testat -Genutzte JDK version ----> Java 25 -public static void main(............) wird zu void main -System.out.print ist IO.print +Shop besteht aus resources und src - -IML dateien werden gepushed, da ich kein aktives Build System nutze \ No newline at end of file diff --git a/Shop/resources/quellen.txt b/Shop/resources/quellen.txt index 33f9ea5..8d540b6 100644 --- a/Shop/resources/quellen.txt +++ b/Shop/resources/quellen.txt @@ -83,3 +83,5 @@ https://softwareengineering.stackexchange.com/questions/347505/how-to-design-the Shopping Cart Java Application (addToCart) https://stackoverflow.com/questions/18473130/shopping-cart-java-application-addtocart +Arrange,act, assert +https://java-design-patterns.com/patterns/arrange-act-assert/ \ No newline at end of file diff --git a/Shop/src/de/th_mannheim/informatik/main/java/shop/frontend/ShopTUI.java b/Shop/src/de/th_mannheim/informatik/main/java/shop/frontend/ShopTUI.java index 3554b1e..60017ad 100644 --- a/Shop/src/de/th_mannheim/informatik/main/java/shop/frontend/ShopTUI.java +++ b/Shop/src/de/th_mannheim/informatik/main/java/shop/frontend/ShopTUI.java @@ -131,7 +131,7 @@ public class ShopTUI { IO.println("\nYour shopping cart:"); IO.println("----------------------------------------"); for (CartPosition pos : cart.getPositions()) { - IO.println(pos); + IO.println(pos.getProduct()); } IO.println("----------------------------------------"); IO.println(String.format("Product value (net): %6.2f €", tempOrder.getTotalNet())); diff --git a/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/CartTest.java b/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/CartTest.java index d923cef..b900929 100644 --- a/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/CartTest.java +++ b/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/CartTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; class CartTest { private Cart cart; @@ -23,4 +24,11 @@ class CartTest { } + @Test + public void testClear() { + cart.addProduct(product1, 2); + cart.clear(); + assertTrue(cart.isEmpty()); + } + } \ No newline at end of file diff --git a/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OnlineShopTest.java b/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OnlineShopTest.java index 4e9af5d..9d60a00 100644 --- a/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OnlineShopTest.java +++ b/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OnlineShopTest.java @@ -1,5 +1,33 @@ 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 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); + } + } \ No newline at end of file diff --git a/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OrderTest.java b/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OrderTest.java index 579aa78..d328089 100644 --- a/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OrderTest.java +++ b/Shop/src/de/th_mannheim/informatik/test/java/shop/backend/OrderTest.java @@ -1,5 +1,8 @@ package shop.backend; class OrderTest { +//Array list + //Product attribute + } \ No newline at end of file