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.

63 lines
1.6 KiB

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