public void CoinExists_returns_if_the_coin_symbol_exists() { var repo = new CoinRepository(); Assert.True(repo.CoinExists("btc")); Assert.True(repo.CoinExists("eth")); Assert.False(repo.CoinExists("blahblah")); Assert.False(repo.CoinExists("")); }
private void LoadCoins(MoneyCollection moneyCollection) { var coinLoader = new CoinRepository(_sqlConnectionProvider); foreach (var coinEntity in coinLoader.Load(moneyCollection.Currency)) { Verifiers.Verify(coinEntity.Count >= 0, "Coins count is less than zero: {0}", coinEntity.Count); moneyCollection.Coins.Add(coinEntity.Nominal, coinEntity.Count); } }
public void SearchForCoins_searches_by_case_insensitive_symbol() { var repo = new CoinRepository(); var coins = repo.SearchForCoins("BTC"); Assert.NotNull(coins); Assert.True(coins.Count > 0); Assert.Contains(coins, x => x.Symbol == "btc"); }
public void SearchForCoins_searches_by_name() { var repo = new CoinRepository(); var coins = repo.SearchForCoins("Wanchain"); Assert.NotNull(coins); Assert.True(coins.Count > 0); Assert.Contains(coins, x => x.Symbol == "wan"); }
private void RemoveCoins(Coins coins, Currency currency) { var coinRepository = new CoinRepository(_sqlConnectionProvider); foreach (var coinEntity in ConvertToCoinEntities(coins, currency)) { coinRepository.Delete(coinEntity); } _totalMoney[currency].Coins.Remove(coins); }
private void AddCoins(Coins coins, Currency currency) { // TODO: may be create repository only one time, cash and then reuse var coinRepository = new CoinRepository(_sqlConnectionProvider); foreach (var coinEntity in ConvertToCoinEntities(coins, currency)) { coinRepository.Insert(coinEntity); } _totalMoney[currency].Coins.Add(coins); }
public async void GetCoinStats_returns_stats_from_price_history() { var repo = new CoinRepository(); var coinStats = await repo.GetCoinStats("btc"); Assert.NotNull(coinStats); Assert.Equal("btc", coinStats.Symbol); Assert.NotNull(coinStats.ProfitableDescription); Assert.NotNull(coinStats.NotProfitableDescription); Assert.NotNull(coinStats.AllTimeHighDescription); }
public async void GetCoinStats_returns_stats_from_cache_on_second_call() { var coinGeckoClient = new Mock <ICoinGeckoClient>(); var coinLogger = new Mock <ICoinLogger>(); var repo = new CoinRepository(coinGeckoClient.Object, new MemoryCache(new MemoryCacheOptions()), coinLogger.Object); coinGeckoClient.Setup(x => x.GetCoinPriceHistory("bitcoin")).ReturnsAsync(new List <CoinGeckoPrice>()); await repo.GetCoinStats("btc"); await repo.GetCoinStats("btc"); await repo.GetCoinStats("btc"); coinGeckoClient.Verify(x => x.GetCoinPriceHistory("bitcoin"), Times.Once); }
public CoinService(HttpClient client) { _repository = new CoinRepository(client); }
public bool Exists(Guid collectionId, Guid coinId) => CoinRepository.Exists(collectionId, coinId);
public IList <CoinModel> GetCoins(Guid collectionId) => CoinRepository.GetCoins(collectionId).Select(Mapper.Map <CoinModel>).ToList();
public CoinsServiceTests(DbContextFixture fixture) { coinRepository = new CoinRepository(fixture.Context); coinsService = new CoinsService(coinRepository); }
public void CoinExists_handles_null() { var repo = new CoinRepository(); Assert.False(repo.CoinExists(null)); }