Browse Source

Added: Javadoc for test_insertItemInWarehouse()

feature-pr/shop
Maxim Volkov 2 years ago
parent
commit
2b8a628c60
  1. 27
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java

27
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/WarehouseTest.java

@ -3,12 +3,9 @@ package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase; import junit.framework.TestCase;
public class WarehouseTest extends TestCase { public class WarehouseTest extends TestCase {
/*
* public void test_fillWareHouseWithItems() { for (int i = 0; i < 10; i++) {
*
* } }
/**
* Check if the insertion of an Item works properly.
*/ */
public void test_insertItemInWarehouse() { public void test_insertItemInWarehouse() {
// Given // Given
Warehouse warehouse = new Warehouse(); Warehouse warehouse = new Warehouse();
@ -22,42 +19,42 @@ public class WarehouseTest extends TestCase {
Item expectedItem = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice); Item expectedItem = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice);
assertNotNull(expectedItem); assertNotNull(expectedItem);
warehouse.insertItem(expectedItem); warehouse.insertItem(expectedItem);
Item gotItem = warehouse.pool.get(expectedTitel); Item gotItem = warehouse.pool.get(expectedTitel);
// Then // Then
assertEquals(expectedTitel, gotItem.getTitel()); assertEquals(expectedTitel, gotItem.getTitel());
} }
/** /**
* Test the total Sum of Items in the whole Warehouse.
* Test the total Sum of Items in the whole Warehouse.
*/ */
public void test_growingCountOfItemsInWarehouse() { public void test_growingCountOfItemsInWarehouse() {
// Given // Given
Warehouse warehouse = new Warehouse(); Warehouse warehouse = new Warehouse();
int unitsPerItemType = 3; int unitsPerItemType = 3;
int expectedSize = 13; int expectedSize = 13;
for(int i = 0; i < expectedSize; i++) {
for (int i = 0; i < expectedSize; i++) {
Item item = new Item("ItemDummy" + i, "DescriptionDummy" + i, unitsPerItemType, 12.0f); Item item = new Item("ItemDummy" + i, "DescriptionDummy" + i, unitsPerItemType, 12.0f);
warehouse.insertItem(item); warehouse.insertItem(item);
} }
int expectedSum = expectedSize * unitsPerItemType; int expectedSum = expectedSize * unitsPerItemType;
int actualSumOfAllItems = warehouse.getCountOfStock(); int actualSumOfAllItems = warehouse.getCountOfStock();
// Then // Then
assertEquals(expectedSum, actualSumOfAllItems); assertEquals(expectedSum, actualSumOfAllItems);
} }
/** /**
* Empty Warehouse means there are a total of zero Items. * Empty Warehouse means there are a total of zero Items.
*/ */
public void test_emptyWarehouse() {
public void test_emptyWarehouse() {
// Given // Given
Warehouse warehouse = new Warehouse(); Warehouse warehouse = new Warehouse();
// When // When
int expectedSum = 0; int expectedSum = 0;
// Then // Then
int actualSumOfAllItems = warehouse.getCountOfStock(); int actualSumOfAllItems = warehouse.getCountOfStock();
assertEquals(expectedSum, actualSumOfAllItems); assertEquals(expectedSum, actualSumOfAllItems);

Loading…
Cancel
Save