You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

  1. package de.hs_fulda.ciip.projjpn;
  2. import junit.framework.TestCase;
  3. public class WarehouseTest extends TestCase {
  4. /*
  5. * public void test_fillWareHouseWithItems() { for (int i = 0; i < 10; i++) {
  6. *
  7. * } }
  8. */
  9. public void test_insertItemInWarehouse() {
  10. // Given
  11. Warehouse warehouse = new Warehouse();
  12. String expectedTitel = "Logitec Maus";
  13. String expectedDescription = "Gaming Maus fuer Fortgeschrittene.";
  14. int expectedQuantity = 10;
  15. float expectedPrice = 69.69f;
  16. // When
  17. Item expectedItem = new Item(expectedTitel, expectedDescription, expectedQuantity, expectedPrice);
  18. assertNotNull(expectedItem);
  19. warehouse.insertItem(expectedItem);
  20. Item gotItem = warehouse.pool.get(expectedTitel);
  21. // Then
  22. assertEquals(expectedTitel, gotItem.getTitel());
  23. }
  24. /**
  25. * Test the total Sum of Items in the whole Warehouse.
  26. */
  27. public void test_growingCountOfItemsInWarehouse() {
  28. // Given
  29. Warehouse warehouse = new Warehouse();
  30. int unitsPerItemType = 3;
  31. int expectedSize = 13;
  32. for(int i = 0; i < expectedSize; i++) {
  33. Item item = new Item("ItemDummy" + i, "DescriptionDummy" + i, unitsPerItemType, 12.0f);
  34. warehouse.insertItem(item);
  35. }
  36. int expectedSum = expectedSize * unitsPerItemType;
  37. int actualSumOfAllItems = warehouse.getCountOfStock();
  38. // Then
  39. assertEquals(expectedSum, actualSumOfAllItems);
  40. }
  41. /**
  42. * Empty Warehouse means there are a total of zero Items.
  43. */
  44. public void test_emptyWarehouse() {
  45. // Given
  46. Warehouse warehouse = new Warehouse();
  47. // When
  48. int expectedSum = 0;
  49. // Then
  50. int actualSumOfAllItems = warehouse.getCountOfStock();
  51. assertEquals(expectedSum, actualSumOfAllItems);
  52. }
  53. }