#Test Methoden implementiert für ONline shop, cart, product
parent
fc3ef498e2
commit
4d105abbf8
|
|
@ -2,9 +2,5 @@
|
||||||
|
|
||||||
Shop Testat
|
Shop Testat
|
||||||
|
|
||||||
Genutzte JDK version ----> Java 25
|
Shop besteht aus resources und src
|
||||||
public static void main(............) wird zu void main
|
|
||||||
System.out.print ist IO.print
|
|
||||||
|
|
||||||
|
|
||||||
IML dateien werden gepushed, da ich kein aktives Build System nutze
|
|
||||||
|
|
@ -83,3 +83,5 @@ https://softwareengineering.stackexchange.com/questions/347505/how-to-design-the
|
||||||
Shopping Cart Java Application (addToCart)
|
Shopping Cart Java Application (addToCart)
|
||||||
https://stackoverflow.com/questions/18473130/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/
|
||||||
|
|
@ -131,7 +131,7 @@ public class ShopTUI {
|
||||||
IO.println("\nYour shopping cart:");
|
IO.println("\nYour shopping cart:");
|
||||||
IO.println("----------------------------------------");
|
IO.println("----------------------------------------");
|
||||||
for (CartPosition pos : cart.getPositions()) {
|
for (CartPosition pos : cart.getPositions()) {
|
||||||
IO.println(pos);
|
IO.println(pos.getProduct());
|
||||||
}
|
}
|
||||||
IO.println("----------------------------------------");
|
IO.println("----------------------------------------");
|
||||||
IO.println(String.format("Product value (net): %6.2f €", tempOrder.getTotalNet()));
|
IO.println(String.format("Product value (net): %6.2f €", tempOrder.getTotalNet()));
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
class CartTest {
|
class CartTest {
|
||||||
private Cart cart;
|
private Cart cart;
|
||||||
|
|
@ -23,4 +24,11 @@ class CartTest {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void testClear() {
|
||||||
|
cart.addProduct(product1, 2);
|
||||||
|
cart.clear();
|
||||||
|
assertTrue(cart.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,33 @@
|
||||||
package shop.backend;
|
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 {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package shop.backend;
|
package shop.backend;
|
||||||
|
|
||||||
class OrderTest {
|
class OrderTest {
|
||||||
|
//Array list
|
||||||
|
//Product attribute
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue