From 343f408977e991278adb2a957acc63e68a94e42c Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 16:28:54 +0100 Subject: [PATCH] Added: Update Availability Test --- .../src/main/java/de/hs_fulda/ciip/projjpn/Item.java | 4 ++++ .../test/java/de/hs_fulda/ciip/projjpn/ItemTest.java | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java index 8b6cc9f..44fc02d 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Item.java @@ -12,4 +12,8 @@ public class Item { public boolean inStock() { return availability > 0; } + + public void updateAvailability(int newAmount) { + availability = newAmount; + } } diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java index c6467ba..1ba1359 100644 --- a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java +++ b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/ItemTest.java @@ -13,4 +13,15 @@ public class ItemTest extends TestCase { // Then assertFalse(notInStock); } + + public void test_ItemInStock() { + // Given + Item item = new Item(); + item.updateAvailability(1); + // When + boolean inStock = item.inStock(); + + // Then + assertTrue(inStock); + } }