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.

54 lines
1.0 KiB

  1. package de.hs_fulda.ciip.projjpn;
  2. import junit.framework.TestCase;
  3. public class ItemTest extends TestCase {
  4. public void test_ItemNotInStock() {
  5. // Given
  6. Item item = new Item();
  7. // When
  8. boolean notInStock = item.inStock();
  9. // Then
  10. assertFalse(notInStock);
  11. }
  12. public void test_ItemInStock() {
  13. // Given
  14. Item item = new Item();
  15. item.updateAvailability(1);
  16. // When
  17. boolean inStock = item.inStock();
  18. // Then
  19. assertTrue(inStock);
  20. }
  21. public void test_priceOfMultipleIdenticalItems() {
  22. // Given
  23. Item item = new Item();
  24. int quantity = 3;
  25. float price = 5;
  26. item.updateAvailability(quantity);
  27. item.updatePrice(price);
  28. // When
  29. float expectedPrice = quantity * price;
  30. // Then
  31. float actualPrice = 0;
  32. for(int i = 0; i < quantity; i++) {
  33. actualPrice += item.getCurrentPrice();
  34. }
  35. assertEquals(expectedPrice, actualPrice);
  36. }
  37. public void test_buildCompleteItem() {
  38. // Given
  39. Item item = new Item("Logitec Maus", "Gaming Maus fuer Fortgeschrittene.", 10, 69.99f);
  40. assertNotNull(item);
  41. }
  42. }