From 467cd34316c0063397e5f731f5c83842df1a77f8 Mon Sep 17 00:00:00 2001 From: Andrzej Pomirski Date: Wed, 12 Mar 2014 13:07:34 +0100 Subject: [PATCH] Add a test for price checking --- .../ChestShop/Tests/PriceCheckerTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/java/com/Acrobot/ChestShop/Tests/PriceCheckerTest.java diff --git a/src/test/java/com/Acrobot/ChestShop/Tests/PriceCheckerTest.java b/src/test/java/com/Acrobot/ChestShop/Tests/PriceCheckerTest.java new file mode 100644 index 0000000..53f7b23 --- /dev/null +++ b/src/test/java/com/Acrobot/ChestShop/Tests/PriceCheckerTest.java @@ -0,0 +1,44 @@ +package com.Acrobot.ChestShop.Tests; + +import com.Acrobot.ChestShop.Events.PreShopCreationEvent; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static com.Acrobot.ChestShop.Listeners.PreShopCreation.PriceChecker.onPreShopCreation; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; + +/** + * Created by Andrzej Pomirski (Acrobot) + */ +@RunWith(JUnit4.class) +public class PriceCheckerTest { + + String[] getPriceString(String prices) { + return new String[]{null, null, prices, null}; + } + + @Test + public void testPrice() { + PreShopCreationEvent event = new PreShopCreationEvent(null, null, getPriceString("B 1")); + onPreShopCreation(event); + assertFalse(event.isCancelled()); + + event = new PreShopCreationEvent(null, null, getPriceString("S 1")); + onPreShopCreation(event); + assertFalse(event.isCancelled()); + + event = new PreShopCreationEvent(null, null, getPriceString("B 1:S 1")); + onPreShopCreation(event); + assertFalse(event.isCancelled()); + + event = new PreShopCreationEvent(null, null, getPriceString("BS 1")); + onPreShopCreation(event); + assertTrue(event.isCancelled()); + + event = new PreShopCreationEvent(null, null, getPriceString("B 1S0")); + onPreShopCreation(event); + assertTrue(event.isCancelled()); + } +}