public void UpdateProductHistoricCandles_ShouldReturnOrderBook_WhenAccountExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( $@"[[1415398768, 0.32, 4.2, 0.35, 4.2, 12.3],[1415398998, 0.33, 4.9, 0.40, 4.5, 15.3]]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); ConnectionAdapter connectionFactory = new ConnectionAdapter(httpClient, _exchangeSettings); Coinbase subjectUnderTest = new Coinbase(connectionFactory); Product product = new Product { ID = "BTC-EUR", BaseCurrency = "BTC", QuoteCurrency = "EUR", BaseMinSize = "0.001", BaseMaxSize = "10000.00", QuoteIncrement = "0.01" }; DateTime startingDateTime = new DateTime(2015, 4, 23).Date.ToUniversalTime(); DateTime endingDateTime = startingDateTime.AddMonths(6).ToUniversalTime(); //Act subjectUnderTest.UpdateProductHistoricCandlesAsync(product, startingDateTime, endingDateTime).Wait(); //Assert Assert.IsNotNull(subjectUnderTest.HistoricRates); Assert.AreEqual(2, subjectUnderTest.HistoricRates.Count); Assert.AreEqual((decimal)0.32, subjectUnderTest.HistoricRates[0].Low); Assert.AreEqual((decimal)12.3, subjectUnderTest.HistoricRates[0].Volume); }
public void UpdateProductHistoricCandles_ShouldReturnOrderBook_WhenAccountExists() { //Arrange _httpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) { StatusCode = HttpStatusCode.OK, Content = new StringContent( @"[[1415398998, 0.33, 4.9, 0.40, 4.5, 15.3],[1415398768, 0.32, 4.2, 0.35, 4.2, 12.3]]") })) .Verifiable(); HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object); _connectionAdapter.HttpClient = httpClient; Coinbase subjectUnderTest = new Coinbase { ConnectionAdapter = _connectionAdapter }; HistoricCandlesSearch historicCandlesSearch = new HistoricCandlesSearch { Symbol = "BTC-EUR", StartingDateTime = new DateTime(2015, 4, 23).Date.ToUniversalTime(), EndingDateTime = new DateTime(2015, 4, 23).Date.ToUniversalTime().AddMonths(6).ToUniversalTime() }; //Act subjectUnderTest.UpdateProductHistoricCandlesAsync(historicCandlesSearch).Wait(); //Assert Assert.IsNotNull(subjectUnderTest.HistoricRates); Assert.AreEqual(2, subjectUnderTest.HistoricRates.Count); Assert.AreEqual((decimal)0.32, subjectUnderTest.HistoricRates[0].Low); Assert.AreEqual((decimal)12.3, subjectUnderTest.HistoricRates[0].Volume); }