package question1;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

public class InventoryManagementTest {
	
	@Test
	public void testExceptions() throws Exception {
		InventoryManagement iv = new InventoryManagement();
		iv.replenish(0, 10, 0);
		assertThrows(ZoneFullException.class, () -> iv.replenish(0, 96, 0));
	}

	@Test
	public void testExceptions2() throws Exception {
		InventoryManagement iv = new InventoryManagement();
		assertThrows(StockOutException.class, () -> iv.distribute(0, 0, 92));
	}

	@Test
	public void testQuantity() throws Exception {
		InventoryManagement iv = new InventoryManagement();
		iv.replenish(2, 42, 0);
		iv.replenish(2, 21, 1);
		iv.replenish(2, 0, 3);
		assertEquals(63, iv.quantity(2));
	}

	@Test
	public void testMove() throws Exception {
		InventoryManagement iv = new InventoryManagement();
		iv.replenish(42, 50, 1);
		iv.move(42, 21, 1, 2);
		assertEquals(50, iv.quantity(42));
	}

	@Test
	public void testFailure() throws Exception {
		InventoryManagement iv = new InventoryManagement();
		iv.replenish(42, 50, 1);
		iv.replenish(42, 50, 2);
		assertEquals(5050, iv.quantity(42)); // Should return a Failure
	}
	
	@Test
	public void testError() throws Exception {
		InventoryManagement iv = new InventoryManagement();
		iv.replenish(42, 100, 1);
		iv.replenish(42, 1, 1); // Should create an error
		
	}
}
