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());
    }
}

@@ -31,16 +31,59 @@
 Tests;%0A%0A
+import com.Acrobot.Breeze.Utils.PriceUtil;%0A
 import c
@@ -1462,16 +1462,439 @@
 lled());
+%0A%0A        String priceString = %225 B 5%22;%0A        assertTrue(PriceUtil.getBuyPrice(priceString) == PriceUtil.NO_PRICE);%0A%0A        priceString = %225 S 5%22;%0A        assertTrue(PriceUtil.getSellPrice(priceString) == PriceUtil.NO_PRICE);%0A%0A        priceString = %225 B 5:5 S 5%22;%0A        assertTrue(PriceUtil.getBuyPrice(priceString) == PriceUtil.NO_PRICE);%0A        assertTrue(PriceUtil.getSellPrice(priceString) == PriceUtil.NO_PRICE);
 %0A    %7D%0A%7D

Add a price test