package io.bisq.gui.util;

import io.bisq.common.locale.Res;
import io.bisq.common.locale.TradeCurrency;
import javafx.util.StringConverter;
import org.junit.Before;
import org.junit.Test;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import static com.natpryce.makeiteasy.MakeItEasy.make;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static io.bisq.common.locale.TradeCurrencyMakers.bitcoin;
import static io.bisq.common.locale.TradeCurrencyMakers.euro;
import static io.bisq.core.user.PreferenceMakers.empty;
import static io.bisq.gui.util.CurrencyListItemMakers.*;
import static org.junit.Assert.assertEquals;

public class GUIUtilTest {

    @Before
    public void setup() {
        Locale.setDefault(new Locale("en", "US"));
    }

    @Test
    public void testTradeCurrencyConverter() {
        Res.setBaseCurrencyCode("EUR");
        Res.setBaseCurrencyName("Euro");
        Map<String, Integer> offerCounts = new HashMap<String, Integer>() {{
            put("EUR", 10);
        }};
        StringConverter<TradeCurrency> tradeCurrencyConverter = GUIUtil.getTradeCurrencyConverter(
                Res.get("shared.offer"),
                Res.get("shared.offers"),
                offerCounts
        );

        assertEquals("★ Euro (EUR) - 10 offers", tradeCurrencyConverter.toString(euro));
    }

    @Test
    public void testCurrencyListWithOffersConverter() {
        Res.setBaseCurrencyCode("BTC");
        Res.setBaseCurrencyName("Bitcoin");
        StringConverter<CurrencyListItem> currencyListItemConverter = GUIUtil.getCurrencyListItemConverter(Res.get("shared.offer"),
                Res.get("shared.offers"),
                empty);

        assertEquals("✦ BTC (BTC) - 10 offers", currencyListItemConverter.toString(make(bitcoinItem.but(with(numberOfTrades,10)))));
        assertEquals("★ Euro (EUR) - 0 offers", currencyListItemConverter.toString(make(euroItem)));
        assertEquals("★ Euro (EUR) - 1 offer", currencyListItemConverter.toString(make(euroItem.but(with(numberOfTrades, 1)))));

    }
}

@@ -838,89 +838,8 @@
 ) %7B%0A
-        Res.setBaseCurrencyCode(%22EUR%22);%0A        Res.setBaseCurrencyName(%22Euro%22);%0A
     
@@ -911,16 +911,44 @@
 r%3E() %7B%7B%0A
+            put(%22BTC%22, 11);%0A
         
@@ -1197,24 +1197,115 @@
         );%0A%0A
+        assertEquals(%22%E2%9C%A6 BTC (BTC) - 11 offers%22, tradeCurrencyConverter.toString(bitcoin));%0A
         asse

Add assert erroneously deleted in last commit.