public async Task GetTradesSafetyAsync_RetryPolicy() { #region arrange int attemptCnt = 0; int successfulAttemptNumber = 4; Func <DateTime, Task <IEnumerable <Trade> > > fnGetTradeAsync = (gmtDate) => { attemptCnt++; if (attemptCnt < successfulAttemptNumber) { throw new Exception("Test exception"); } Trade[] tradeArray = new[] { Trade.Create(gmtDate, 24) }; return (Task.FromResult((IEnumerable <Trade>)tradeArray)); }; var tradingDataAdapter = new TradingDataAdapter(); #endregion // act var trades = await tradingDataAdapter.GetTradesSafetyAsync(DateTime.Now, fnGetTradeAsync); // assert trades.Should().NotBeNull(); attemptCnt.Should().Be(successfulAttemptNumber); }
public async Task TradingDataAdapterIntegrationTest() { // Check base integration with TradingPlatform.TradingService // arrange TradingDataAdapter tradingDataAdapter = new TradingDataAdapter(); // act var trades = await tradingDataAdapter.GetTradesSafetyAsync(DateTime.Now); // assert trades.Should().NotBeNull(); foreach (var trade in trades) { trade.Periods.Should().NotBeNull(); trade.Periods.Length.Should().BeGreaterOrEqualTo(23); } }