Esempio n. 1
0
        public void GivenTokenConverter_WhenVolumeWithFiat_ThenFail()
        {
            var currencyToken  = new CurrencyToken("EUR", "EUR", CurrencyType.Fiat);
            var tokenConverter = CreateTokenConverter();

            var result = tokenConverter.ToUsdVolume(currencyToken);

            Assert.Fail();
        }
Esempio n. 2
0
        public void GivenTokenConverter_WhenHasRankOrHigherWithFiat_ThenFail()
        {
            var numberToken    = new NumberToken("4");
            var currencyToken  = new CurrencyToken("EUR", "EUR", CurrencyType.Fiat);
            var tokenConverter = CreateTokenConverter();

            var result = tokenConverter.HasRankOrHigher(numberToken, currencyToken);

            Assert.Fail();
        }
        public decimal ToUsdMarketCap(CurrencyToken currencyToken)
        {
            if (currencyToken.CurrencyType == CurrencyType.Fiat)
            {
                throw new ArgumentException("MarketCap only accepts crypto currencies.");
            }

            var currency = currencyService.GetByTicker(currencyToken.Ticker);
            var info     = coinMarketCapClient.Ticker(currency.CoinMarketCapId);

            return(info.Market_cap_usd);
        }
 public decimal ToUsdPrice(CurrencyToken currencyToken)
 {
     if (currencyToken.CurrencyType == CurrencyType.Fiat)
     {
         var rates = fixerClient.GetUsdRates();
         return(rates.Rates[currencyToken.Ticker]);
     }
     else
     {
         var currency = currencyService.GetByTicker(currencyToken.Ticker);
         var info     = coinMarketCapClient.Ticker(currency.CoinMarketCapId);
         return(info.Price_usd);
     }
 }
        public InterpreterResult HasRankOrHigher(NumberToken numberToken, CurrencyToken currencyToken)
        {
            var expectedRank = numberToken.NumericValue;

            if (expectedRank < 1)
            {
                throw new ArgumentOutOfRangeException("Rank must be 1 or higher");
            }

            if (currencyToken.CurrencyType == CurrencyType.Fiat)
            {
                throw new ArgumentException("HasRankOrHigher only accepts crypto currencies.");
            }

            var currency = currencyService.GetByTicker(currencyToken.Ticker);
            var info     = coinMarketCapClient.Ticker(currency.CoinMarketCapId);

            return(new InterpreterResult(expectedRank <= info.Rank, null));
        }