コード例 #1
0
        public void TwentyFourHoursRollingStats_ShouldReturnStatistics()
        {
            //Arrange
            _httpMessageHandlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync",
                                                 ItExpr.Is <HttpRequestMessage>(x => x.RequestUri.AbsoluteUri.Contains("/api/v3/ticker/24hr")),
                                                 ItExpr.IsAny <CancellationToken>())
            .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(
                    @"{""symbol"": ""BNBBTC"",
                        ""priceChange"": ""-94.99999800"",
                        ""priceChangePercent"": ""-95.960"",
                        ""weightedAvgPrice"": ""0.29628482"",
                        ""prevClosePrice"": ""0.10002000"",
                        ""lastPrice"": ""4.00000200"",
                        ""lastQty"": ""200.00000000"",
                        ""bidPrice"": ""4.00000000"",
                        ""askPrice"": ""4.00000200"",
                        ""openPrice"": ""99.00000000"",
                        ""highPrice"": ""100.00000000"",
                        ""lowPrice"": ""0.10000000"",
                        ""volume"": ""8913.30000000"",
                        ""quoteVolume"": ""15.30000000"",
                        ""openTime"": 1499783499040,
                        ""closeTime"": 1499869899040,
                        ""firstId"": 28385,
                        ""lastId"": 28460,
                        ""count"": 76}")
            }))
            .Verifiable();
            HttpClient httpClient = new HttpClient(_httpMessageHandlerMock.Object);

            _connectionAdapter.HttpClient = httpClient;
            Binance subjectUnderTest = new Binance
            {
                ConnectionAdapter = _connectionAdapter
            };
            Product product = new Product {
                ID = "BNBBTC"
            };
            //Act
            Statistics statistics = subjectUnderTest.TwentyFourHoursRollingStatsAsync(product).Result;

            //Assert
            Assert.IsNotNull(statistics);
        }