public async Task GetCryptoCurrenciesAsync_WithoutActiveCryptoCurrency_ReturnListIsEmpty() { // Arrange Initialize(); var getCryptoCurrencies = new GetCryptoCurrencies { Status = new StatusData { ErrorCode = 0 }, CryptoCurrencies = new List <CryptoCurrencyData> { new CryptoCurrencyData { Id = 1, IsActive = false, Name = "Bitcoin" } } }; _coinMarketCapProxy.Setup(x => x.GetCryptoCurrenciesAsync()).ReturnsAsync(getCryptoCurrencies); // Act var result = await _cryptoCurrencyService.GetCryptoCurrenciesAsync(); // Assert Assert.NotNull(result); Assert.True(result.Count() == 0); _coinMarketCapProxy.Verify(x => x.GetCryptoCurrenciesAsync(), Times.Once); }
private async Task DisplayCryptoCurrencies() { _console.WriteLine("Getting Data Started... Please Be Patient!"); IEnumerable <CryptoCurrency> cryptoCurrencies = await _cryptoCurrencyService.GetCryptoCurrenciesAsync().ConfigureAwait(false); bool hasDataToDisplay = cryptoCurrencies != null && cryptoCurrencies.Any(); _console.WriteLine($"There Is/Are {(hasDataToDisplay ? cryptoCurrencies.Count() : '0')} Crypto Currency/ies"); if (hasDataToDisplay) { var maxNameLenght = cryptoCurrencies.ToList().Max(x => x.Name.Length); cryptoCurrencies.ToList().ForEach(x => { _console.WriteLine($"Name: {x.Name.PadRight(maxNameLenght, '-')} Symbol: {x.Symbol}", System.ConsoleColor.Green); }); } await EndOfDisplayData(); }